Appending localStorage with dynamic content
Clash Royale CLAN TAG #URR8PPP Appending localStorage with dynamic content I am generating image coordinates at various locations within a image which I am saving to a localStorage item. For example: var coords = ; coords.push(Math.round(dragStopLocation.x),Math.round(dragStopLocation.y)); The above stores the values in coords variable. I am setting this to localStorage using: localStorage.setItem('coords', JSON.stringify(coords)); This as a standalone code works well. Since, the item coords is dynamic and many arrays of coords is possible, I want to append the item coords with new arrays. I am using the following code: coords coords coords //Save the original coords items in a variable var old_coords = localStorage.getItem('coords'); //append if (old_coords === null) { localStorage.setItem('coords', JSON.stringify(coords)); } else { localStorage.setItem('coords', old_coords + JSON.stringify(coords)); } I tried one more ...