Can anyone help me plz? When i use + sign the sum become wrong. But in case of -*/% that code looks fine. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone help me plz? When i use + sign the sum become wrong. But in case of -*/% that code looks fine.

https://code.sololearn.com/WXlEIQ8dO41X/?ref=app

6th Jan 2018, 5:37 AM
M.I Shanto
M.I Shanto - avatar
2 Answers
+ 2
Since the input, the variables 'a' and 'b' are strings. So, the doSum() function concatenates the parameters one and two, if you're passing strings as arguments (instead of integers) and then trying to sum them with the + operator. Use the parseInt() function, to convert a and b to integers. Example: var m = parseInt(a); var n = parseInt(b);
6th Jan 2018, 6:35 AM
Boris Batinkov
Boris Batinkov - avatar
+ 5
This is a JavaScript question. This is nothing relates to C#, Python, C++, Java questions. Please don't polluted the usage of tags, delete all irrelevant tags.
6th Jan 2018, 8:58 AM
Calviղ
Calviղ - avatar