local-storage allows to read and write its value to the key in localStorage. The type attribute allows to place the validation constrains to the value: when the value does not match the expected type, it would not be assigned, keeping empty value instead.

Has to produce 12πŸ’

Click the fruits button to add into cart

localStorage content

The demo should display count 1πŸ‹ and 12πŸ’ initially. The value in localStorage is incremented when clicked on matching button

Click to add the localStorage value
keyvalue