Home

Published

- 1 min read

javascript store array in localstorage

img of javascript store array in localstorage

The solution for this is noted below

javascript store array in localstorage

Solution

   //storing array in localStorage

var colors = ['red', 'blue', 'green']

localStorage.setItem('my_colors', JSON.stringify(colors)) //store colors

var storedColors = JSON.parse(localStorage.getItem('my_colors')) //get them back

Try other methods by searching on the site. That is if this doesn’t work