Let's start by opening your browser. Type about:blank into the address bar, and make sure your developer console is open. In chrome you can open your developer tools with the shortcut Command+Option+i.
b = 11; c = b + 19; console.log( c );
You should see the value "30" printed in your developer console.
So far we have seen how to output values, but how about input? Normally you would get input values from form values. For learning purposes let's use prompt(..) for our input values.
year = prompt( "What year were you born?" ); console.log( year );
This should output something like this:
Earlier we saw that
= are operators.
+ performs mathematic addition.
= is used for assignment. We first calculate the value on the right and then assign the value to the variable on the left of
var is not an operator, but it is how you declare variables.
You should assign variables before they are used, but only once while in scope.
var b = 30; b = b + 1; b = b * 2; console.log( b );
This should log
Fill out the form below.