+ 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! :)

22nd Feb 2021, 1:30 AM
TheCoder
15 Answers
+ 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.
22nd Feb 2021, 1:31 PM
Alex
Alex - avatar
+ 8
bob your answer is the best IMHO. The simpliest way is the best way especially for a beginner 👍
22nd Feb 2021, 10:21 PM
Alex
Alex - avatar
+ 8
You're welcome bobTheCoder I'll be glad to know more about your project and further updates 😉
23rd Feb 2021, 12:39 PM
Alex
Alex - avatar
+ 3
you need to integrate your web app with mongoDB or MYSQL.
22nd Feb 2021, 1:58 AM
Hima
Hima - avatar
+ 3
TheCoder You need database for this.
22nd Feb 2021, 2:29 AM
A͢J
A͢J - avatar
+ 3
Hima I Am AJ ! Okay, thanks! I will have to learn that first though lol 🤣🤣🤣
22nd Feb 2021, 2:46 AM
TheCoder
22nd Feb 2021, 3:23 AM
SAN
SAN - avatar
+ 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.
22nd Feb 2021, 4:17 PM
bob
bob - avatar
+ 3
Thanks
22nd Feb 2021, 10:48 PM
bob
bob - avatar
+ 2
ŚĄŃ okay, thanks! 👍 I am currently researching and trying to understand stuff lol 😅
22nd Feb 2021, 3:30 AM
TheCoder
+ 2
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! :)
22nd Feb 2021, 11:51 PM
TheCoder
+ 2
Sorry it is 000webhost.com
22nd Feb 2021, 11:52 PM
bob
bob - avatar
+ 1
bob got it, thanks! :)
23rd Feb 2021, 3:00 AM
TheCoder
+ 1
you could store it in a file
23rd Feb 2021, 6:12 PM
Gizmo-Lang
Gizmo-Lang - avatar