how to set array in localstorage code example
Example 1: javascript store array in localstorage
var colors = ["red","blue","green"];
localStorage.setItem("my_colors", JSON.stringify(colors));
var storedColors = JSON.parse(localStorage.getItem("my_colors"));
Example 2: localstorage save array
var names = [];
names[0] = prompt("New member name?");
localStorage.setItem("names", JSON.stringify(names));
var storedNames = JSON.parse(localStorage.getItem("names"));
Example 3: set array of objects in localstorage
localStorage.setItem("savedData", JSON.stringify(objects));
objects = JSON.parse(localStorage.getItem("savedData")));