-3

I am trying to make a simple game in browser without using any backend. Is there a way for me to store the highest score in the browser using only javascript or react?

pau
  • 88
  • 6

1 Answers1

2

Yes , of course . You can use localStorage , this will alow you to store any information in the browser and fetch it later.

Example :

let score = 0;
score = 50;
localStorage.setItem('currentScore', score);

// And if you want to get the score

let getCureentScore = localStorage.getItem('score');

// do something with getCurrentScore

Hope this could helps you :)

Ahmed Ali
  • 1,908
  • 14
  • 28
Marin Terziyski
  • 221
  • 1
  • 11
  • thank you so much for your response. Do you know what could be easier/better? React / vanilla js? Thank you for your patience, I am new to this! – pau Nov 17 '19 at 07:15
  • In react or js app you can use it like in the example above , but if you want to do something else , maybe in react they have some additional packages. – Marin Terziyski Nov 17 '19 at 07:21