• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: I have a problem with the ‘+=’ operator in NodeJs: when I add a number variable to an another number variable it combine them together

Resolved: I have a problem with the ‘+=’ operator in NodeJs: when I add a number variable to an another number variable it combine them together

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

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 🥺

Answer:

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

If you have better answer, please add a comment about this, thank you!

javascript node.js operators
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: When converting markdown to latex with pandoc, how can I end a block before the next heading?

26/03/2023

Resolved: TYPO3 SQL error: Field ‘tx_imagezoom_set’ doesn’t have a default value

26/03/2023

Resolved: std::regex_replace to replace multiple combinations

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.