0
Can anyone help me plz? When i use + sign the sum become wrong. But in case of -*/% that code looks fine.
2 Respostas
+ 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);
+ 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.