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 AMTheCoder
15 AnswersNew Answer
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.
bob your answer is the best IMHO. The simpliest way is the best way especially for a beginner 👍
You're welcome bob ☺ TheCoder I'll be glad to know more about your project and further updates 😉
you need to integrate your web app with mongoDB or MYSQL.
TheCoder You need database for this.
Hima I Am AJ ! Okay, thanks! I will have to learn that first though lol 🤣🤣🤣
Mostly sololearn users use firebase https://firebase.google.com/ https://code.sololearn.com/WXd7HMYvKfkh/?ref=app
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.
ŚĄŃ okay, thanks! 👍 I am currently researching and trying to understand stuff lol 😅
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! :)
Sorry it is 000webhost.com
Use firebase. Even professionals uses that too
bob got it, thanks! :)
you could store it in a file