0
Challenge · 06Just Enough JavaScript
Values, variables and printing
JavaScriptused in ~90% of apps
Before you can solve anything you need somewhere to put things and a way to look at them. This is the whole of that. It takes ten minutes and you will use it in every problem for the rest of your life.
Core idea. A value is a piece of information. A variable is a name you give a value so you can use it later. Printing shows you a value while your code is running, which is how you find out what your code is actually doing rather than what you hoped.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
The three kinds of value you will use
number
7
counts, positions, totals
-3 and 0 are numbers too
string
"ravi"
text, always in quotes
the quotes are not part of it
boolean
true
yes or no, nothing else
only true or false exist
a variable is a label on a value
let total = 0;
total = total + 7; // the label stays, the value changes
console.log(total); // shows 7↑ play a little first, then dig in