Can I save JS variables online? | SoloLearn: Learn to code for FREE!

+2

Can I save JS variables online?

Currently, I'm making a quiz about programming. After completing it, the scores will be compared and sorted to make a leaderboard! But this is the problem... As you can see, I don't know how to save JS variables online! (Meaning anyone from any device can see it, not just 1 device) By the way, I know about localStorage and sessionStorage but I'm not talking about those because they are only visible to 1 device and not every single device... Thanks! :)

2/22/2021 1:30:08 AM

TheCoder

15 Answers

New Answer

+6

Having a leaderboard is cool but looks like you need to learn a lot more than JS in order to make it happen. You project can become more complicated and time consumung. Having an oline database is good but it is not the only option. In fact you would need to pay for it. On top of that many online service companies make you buy subscriptions for their services and pay them before your game earns you any money. I suggest other alternatives you can use while you don't have the needed skills and/or Internet server. First. You can have the highsore variable hashed (to prevent cheating) and ready to be emailed by the user to you. You can post those highscores on your static page regularly. Let's say once a week. Second. Share the results on social media platforms. This way you can get even more attention to your quiz.

+5

bob your answer is the best IMHO. The simpliest way is the best way especially for a beginner 👍

+5

You're welcome bob ☺ TheCoder I'll be glad to know more about your project and further updates 😉

+2

you need to integrate your web app with mongoDB or MYSQL.

+2

TheCoder You need database for this.

+2

Hima I Am AJ ! Okay, thanks! I will have to learn that first though lol 🤣🤣🤣

+2

Mostly sololearn users use firebase https://firebase.google.com/ https://code.sololearn.com/WXd7HMYvKfkh/?ref=app

+2

Na, y'all all giving over complicated answers! Just upload your root directory to a website like 000webhostapp.com and then use PHP to make a leaderboard.txt file, and append new scores to the file using a form. Then you can read the file and give it back to your index.html file any time using PHP.

+2

Thanks

+1

ŚĄŃ okay, thanks! 👍 I am currently researching and trying to understand stuff lol 😅

+1

Alex thanks a lot for your advice!!! Seems like there is no such thing as free lunch lol 😅 Maybe I'll have to regularly update the leaderboard then... bob I'll try that, thanks! :) Also, I tried to go to 000webhostapp.com but it refused to connect... well, I'll try again later! Thanks anyway! :)

+1

Sorry it is 000webhost.com

+1

Use firebase. Even professionals uses that too

0

bob got it, thanks! :)

0

you could store it in a file