Q: 2
Which code statement below correctly persists an objects in local Storage ?
Options
Discussion
Maybe A, since only that option actually stringifies the object before storing. D looks like a trap with that fake persist method.
A tbh
A Pretty sure because it uses setItem with JSON.stringify, which is the right way to store objects in localStorage.
Had something like this in a mock. A is the only one using setItem with JSON.stringify, which you need to turn the JS object into a string for localStorage. The rest either use wrong methods or miss parameters. Pretty sure A is correct here.
Be respectful. No spam.