en.javascript.info/1-js/4-data-structures/2-number/1-sum-interface/solution.md
2016-03-06 00:59:16 +03:00

12 lines
No EOL
320 B
Markdown

```js run demo
let a = +prompt("The first number?", "");
let b = +prompt("The second number?", "");
alert( a + b );
```
Note the unary plus `+` before `prompt`. It immediately converts the value to a number.
Otherwise, `a` and `b` would be string their sum would be their concatenation, that is: `"1" + "2" = "12"`.