You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi @gangasingh94160 in js if we using + operation with string variables it perform concatenation of string but if we use any mathematical operator with string it will perform mathematical operation . That's why your code give this output
61*67 = 4087
'4087'+'53'= 408753
To fix this convert the firstarg to number or call your method like this: console.log(math(53, '61', '67'));
If you like this explanation ,please provide thumbsup and close this issue
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
My Code
'''js
function math (firstArg, secondArg, thirdArg) {
var g = secondArg * thirdArg
return g += firstArg;
}
console.log(math('53', '61', '67'));
the output it shows is 408753.
whereas, the solution is 4140.That is 4087+53.
it is joins the numbers rather than adding them.
The text was updated successfully, but these errors were encountered: