I have two js files. In one file, I am creating an array of objects and storing them in local storage. In another file, I am retrieving highscores_list
from localStorage
.
I get an error at this line stating:
VM2055:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1'
File 1
var highscores_list = [
{name:'sham' , score: 10},
{name:'John' , score: 9}
];
localStorage.setItem('highscores_list',JSON.stringify(highscores_list));
File 2
var getListItems = JSON.parse(localStorage.getItem('highscores_list'));