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

181
Views
I have a problem with the '+=' operator in NodeJs: when I add a number variable to an another number variable it combine them together
const ricarica = (conto, deposito) => {
    deposito = prompt("Quanti soldi vuole depositare sul suo conto? ");
    
    conto += deposito;
    return console.log(`Ora il suo conto ha una disponibilità residua di ${conto}€`);
}

If the 'conto' statement is equal to 0 and 'deposito' is equal to 200, the final output is 0200.

I've tried to convert 'deposito' and 'conto' into float values but nothing changed.

Please help me to solve this problem 🥺

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

0

Since Javascript is loosely-typed, it is viewing conto and deposito as strings and appending them. Convert the to numbers before performing the addition:

let a = Number.parseInt(conto);
let b = Number.parseInt(deposito);
a += b;
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!