title: JSON.stringify of an array returns a number after pushing more than one object
body: <p>I am trying to add products to the cart in my website with localStorage, so I initialize an array and then push products into it. The problem is when I use JSON.parse() to push a product and then stringify it again with JSON.stringify() it returns a number instead of the array. This is the part of my code that throws an error:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let product = {
                  id: i + 1,
                  name: productNames[i].innerText,
                  price: prices[i].innerHTML,
                  img: imgs[i].src
              };
  
              if(localStorage.productsInCart) {
                  let productsInLocalStorage = JSON.parse(localStorage.getItem("productsInCart") || "[]");
                  console.log(productsInLocalStorage);
                  let newArray = productsInLocalStorage.push(product);
                  console.log(JSON.stringify(newArray));
                  localStorage.productsInCart = JSON.stringify(newArray);
                  numberOfProducts.innerHTML = parseInt(numberOfProducts.innerHTML, 10) + 1;
  
              } else {
                  let productToStore = JSON.stringify([product]);
                  localStorage.setItem("productsInCart", productToStore);
                  numberOfProducts.style.display = "block";
                  numberOfProducts.innerHTML = 1;
              };</code></pre>
  </div>
  </div>
  </p>
  <p>And then in the console:
  <a href="https://i.stack.imgur.com/eifaP.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>That circled 2 is the console.log() of the JSON.stringify. I have been searching for detailed info about this but nothing seems to work.</p>