Javascript lesson 2 - variables, appending strings, adding numbers

preview_player
Показать описание
Today we talk about the use of variables - we show you how to append string variables together and how to add numerical variables, then output the result to the screen.

Рекомендации по теме
Комментарии
Автор

Good lesson thanks! I've got a quick question though, can you help me? I'm trying to add 3 numbers and display it by affecting a <p> tag. However, when I try and add the numbers it just adds the string instead (so for example it'll say 1+2+3 = 123). I've tried everything, i don't know what to do :(

<!doctype html>

<html lang="en">
<head>


<title>Second Test!</title>

<p>please enter in 3 numbers</p><br>
<p>a=</p><input id="a" id="b" id="c" type="number"></input><br>
<input type="button" value="find the roots" onclick="solve();"><br>

<p id="first_root"></p>
<body>
<script>
          

function solve() {
x =
y =
z =
= x+y+z;
}


</script>

</body>
</html>

matthewjames