-4

I've tried to get a save function getting triggered by a button to work but when I search on every storage possible i don't find anything so I need to know what I'm doing wrong or what lacks the code

function savewm(){
 var save = {
     plus1: plus1,
 }
 localStorage.setItem('save', JSON.stringify(savewn));
};
seirei
  • 1

2 Answers2

0

You mistakenly stored savewn which is a function instead of the save object.

Also, plus1 is undefined which will cause an error.

You could try this to work.

function savewm(){
var save = {
    plus1: 'test1',
}
localStorage.setItem('save', JSON.stringify(save));
};
Dencio
  • 518
  • 3
  • 12
0

The only way for you to find out if it is really saved is using the localStorage.getItem(). If getItem returns you something, it is saved. Then the problem would be, you probably looked at the wrong place with your browser.

console.log(localStorage.getItem('save'));
Desmond
  • 149
  • 1
  • 2
  • 11