+ 3

How would I save to localSotrage() in the following code?

In the following code, called “Choose your profile Image”, i got multiple images you can choose from. The image you chose will display at the top. I’m wondering if I can save that to local storage. So... for example if you choose image 2, next time you come to the code, your profile image will be image 2, unless you change it. https://code.sololearn.com/WugC4ZSZCudF/?ref=app

20th Mar 2020, 7:48 AM
Ginfio
Ginfio - avatar
6 Respostas
+ 2
Ginfio Local storage will not work here on Sololearn. It will work only on browser. You can set the image in local storage with key every time when user click on image like this. localStorage.set("key", "image"); Here key maybe per user wise.
20th Mar 2020, 8:13 AM
A͢J
A͢J - avatar
+ 1
If you are using the sololearn app on iOS device you can use local storage. https://code.sololearn.com/WBEDb4ikkZvP/?ref=app
20th Mar 2020, 8:47 AM
ODLNT
ODLNT - avatar
+ 1
ODLNT Thank you. That makes sense now.
20th Mar 2020, 8:41 PM
Ginfio
Ginfio - avatar
0
AJ Anant I think it does. For example in this code, i typed in the prompt as Abc. when i go back to it it shows Abc. https://code.sololearn.com/WKobn6bb1Q8r/?ref=app I just didn’t really understand how i would do the same thing in my code, since it’s a little different.
20th Mar 2020, 8:23 AM
Ginfio
Ginfio - avatar
0
ODLNT Do you know how i would use localStorage in my code? It’s a little different_ that’s what’s difficult about it.
20th Mar 2020, 8:49 AM
Ginfio
Ginfio - avatar
0
Ginfio You need to get the image saved in localStorage earlier in your code. https://code.sololearn.com/WatmxVGkoGzK/#html;
20th Mar 2020, 10:32 AM
ODLNT
ODLNT - avatar