Sum of two numbers with prompt

后端 未结 8 2478
甜味超标
甜味超标 2020-11-28 14:47

I\'ve been trying to solve this problem for the last couple days: when I subtract, multiply or divide 2 numbers input through a prompt, everything works fine; but when I wan

8条回答
  •  醉话见心
    2020-11-28 15:33

    You are using concatination operation instead of arithmetic operator.

    In your above code:

    alert(a + b);
    

    Your browser compiler will assume it as concatination. So it concatinating two strings. That is why you are getting that output.

提交回复
热议问题