+ 3
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! :)
15 Réponses
+ 9
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.
+ 8
bob your answer is the best IMHO. The simpliest way is the best way especially for a beginner 👍
+ 3
you need to integrate your web app with mongoDB or MYSQL.
+ 3
TheCoder
You need database for this.
+ 3
Mostly sololearn users use firebase
https://firebase.google.com/
https://code.sololearn.com/WXd7HMYvKfkh/?ref=app
+ 3
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.
+ 3
Thanks
+ 2
ŚĄŃ okay, thanks! 👍 I am currently researching and trying to understand stuff lol 😅
+ 2
Sorry it is 000webhost.com
+ 1
bob got it, thanks! :)
+ 1
you could store it in a file