-2
Hello, I need someone to tell me how to make a system to save my points in java script, I will provide my html css and javascript, here are mine codigos:
let add = document.getElementById('increment');
let int = document.getElementById('number');
let integer = 0;
add.addEventListener('click', function(){
integer += 1;
int.innerHTML = integer;
})
@import url('https://fonts.googleapis.com/css2?family=Nova+Square&display=swap');
body{
background-color: #333232;
font-family: 'Nova Square', cursive;
}
#container{
height: 200px;
width: 500px;
border: 10px solid #926981;
margin: 50px auto;
background-color: #888169;
}**
h1{
text-align: center;
color: white;
}
#number{
height: 25px;
width: 250px;
margin: 50px auto;
border: 1px solid black;
text-align: center;
background-color: white;
}
#increment{
height: 50px;
width: 100px;
margin-top: 50px;
align-items: center;
margin-left: 190px;
}
<h1>ClickxTraffic | Earn Clicking</h1>
<div id="container">
<div id="number">0</div>
<button id="increment">+</button>
</div>
Please I need help.
Your code is working as expected, by clicking the "+" button the number is incremented and displayed. Better define what you mean by "save my points".
– Laércio Lopes
Important you [Dit] your question reducing the problem to a [mcve]. To understand what kind of question serves the site and, consequently, avoid closures and negativities worth reading What is the Stack Overflow and the Stack Overflow Survival Guide (summarized) in Portuguese.
– Bacco
What do you mean by saving your points? And how will you use the result of this save?
– Augusto Vasques
ola Laercio, I need a code for when the person leaves or refresh the page her points continue
– TiohStitch
ola ugusto, I need a code for when the person leaves or refresh the page her points continue
– TiohStitch
Why not save the score on the server, in the database?
– Augusto Vasques
i am beginner in html js and etc, I don’t have it
– TiohStitch
Do you want to make a game without the back end? If save in the browser will have how to cheat your game.
– Augusto Vasques
how do I use it? please tell me
– TiohStitch
To save in the browser use Localstorage. Example: To save
window.localStorage.setItem('Pontos', '1250');
to readwindow.localStorage.getItem('Pontos');
– Augusto Vasques
Could you please tell me the code? I need it so much, create the code, please I need it so much
– TiohStitch
The code is this:
window.localStorage.setItem('Pontos', '1250');
that records in the recordPontos
the value1250
and when you want to read in a variablelet p = window.localStorage.getItem('Pontos');
which places the value of the recordPontos
inp
, that is to sayp
is worth1250
.– Augusto Vasques
I’ll test it and tell you
– TiohStitch
tried so and did not: Let add = Document.getElementById('increment'); Let remove = Document.getElementById('decrement') Let int = Document.getElementById('number'); Let integer = 0; 
 add.eventaddlistener('click', Function(){ integer += 1; int.innerHTML = integer; }) window.localStorage.setItem('number', '10'); window.localStorage.getItem('number'');
– TiohStitch
could you just put the code? got a little confused
– TiohStitch
@Tiohstitch see an example using your https://codepen.io/AugustoVasques/pen/jOydJE?editors=1111
– Augusto Vasques
i tried to use your code but when I give Reload on the page and click it back to 1 then n works
– TiohStitch