r/ProgrammerTIL • u/Sloss_Gaming • Nov 03 '17
Other Node.js
Doing addition in a string, will just insert both numbers into the string, solved with math dependicy
0
Upvotes
r/ProgrammerTIL • u/Sloss_Gaming • Nov 03 '17
Doing addition in a string, will just insert both numbers into the string, solved with math dependicy
7
u/alzee76 Nov 03 '17
It's called string concatenation, and lots of languages besides javascript have it.
5
u/MacHaggis Nov 03 '17
I guess when all you know is javascript and it's quirks, it's surprising when you meet some consistency.
4
u/JoshWithaQ Nov 03 '17
Use parseInt() or parseFloat()
7
u/TankorSmash Nov 03 '17
What do you mean by 'math dependicy', or even 'math dependency'?
1
u/burntferret Mar 24 '18
Or, you can surround your math portions in parentheses.