How? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How?

How use localStorage.setItem and localStrage.getItem with JS, because he added numbers and not chars

26th Dec 2017, 12:05 PM
Crinax
Crinax - avatar
1 Answer
+ 1
if (typeof(Storage) === 'undefined') { /*browser does not support localstorage*/ } else { /* storage code goes here */ } localStorage.setItem(key, value); Sets a value to a key. localStorage.getItem(key); Returns a key's value localStorage.clear(); Clears the storage Local storage can only use strings. Convert your variables to string when setting them and convert them back when accessing
4th Jan 2018, 1:03 PM
Lil Taco
Lil Taco - avatar