I’m trying to create a point system that will do different actions after certain points this is my JS:
if (localStorage.points222){
localStorage.points222=Number(localStorage.points222) +5;
}
else{
localStorage.points222=0;
}
if(localStorage.points222 > 35){
$('#hi').show();
}
else{
$('#hi').hide();
}
document.write("Points: " + localStorage.points222 + "");
Then I have the HTML that I want to fadeIn after 35 points:
<div id="hi" style="display:none;">30!</div>
The problem is that the IF:
if(localStorage.points222 > 35){
$('#hi').show();
}
else{
$('#hi').hide();
}
Is not working…
Only this works:
if(localStorage.points222!==35){
$('#hi').show();
}
else{
$('#hi').hide();
}
But I don’t want #hi to only show at 35 I need it too show from 35 and Up
I bet the problem is that the local storage is coming back as a string, but you’re treating it like a number. You need