Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Can't add to variable

so I have problem with basics cause my variable when i add 1 or just increment gives back nan I don't really know if it's problem with saving or it just can't add. here is code that contains that variable

let add;

if(localStorage.getItem("add")>=1){
    add=localStorage.getItem("add");
  }
  else {
    add = 1;
    localStorage.setItem("add", add);
  }
  
  function oncl(){

add = add++;
 localStorage.setItem("add",add);

}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

nan means it is not a number because localStorage.getItem() returns a string not a number so you need to parse it into a number first then you can do numbers operations

if you are using integers use

parseInt(localStorage.getItem("add")) 
//you can also use parseFloat() or Number()
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!