+ 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
6 odpowiedzi
+ 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.
+ 1
If you are using the sololearn app on iOS device you can use local storage.
https://code.sololearn.com/WBEDb4ikkZvP/?ref=app
+ 1
ODLNT Thank you.
That makes sense now.
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.
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.
0
Ginfio
You need to get the image saved in localStorage earlier in your code.
https://code.sololearn.com/WatmxVGkoGzK/#html;