Can't render my items in to shopping cart javascript

There is nothing wrong with the code you posted but there is no connection between the state used on the two different pages. Each page has its own version of the code with a separate state.

You can use localStorage to share the state between pages (save the products and cart to localStorage and get the data on page load).


I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').


@bappyasif It is just a browser web API. Maybe you copied it without fixing the quotes (when the code posted isn’t properly formatted using backticks the forum will replace the quotes)