javascript · level 1 · unit 2 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Give every box a name that tells you what is inside.
Names can use letters, digits, _ and $. They cannot contain spaces or start with a digit. A like let or const is taken, because JavaScript keeps those words for itself.
A good name says what is inside. x could be anything, but petName explains itself. Case matters too, so petName and petname are two different boxes.
If a name needs several words, squash them together and start each new word with a capital, like bestFriend. This style is called , because the capitals stick up like a camel's humps.
let bestFriend = "Priya";
console.log("My best friend is " + bestFriend); A camelCase name starts with a small letter, so it is bestFriend, not BestFriend.
guess first
Is this a good name? Guess what happens.
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
let 2ndPlace = "Ollie";
console.log(2ndPlace);
your turn
Your turn. Name a box yourself.
Choose a camelCase name for the box, like bestFilm, and type it in both name blanks. Put a film between the quotes, then press run.
fix it
This name has a gap in it. Can you fix it?
- JavaScript cannot read line 1. Look closely at the name of the box.
- Names cannot contain spaces. Squash the two words together in camelCase.
- Change favourite colour to favouriteColour on both lines, then press run.
nailed it
your boxes have good names now. :D
- Names cannot have spaces or start with a digit.
- Pick names that say what is inside the box.
- Join words in camelCase, like
bestFriend.
new words in your collection
- keyword
- camelCase
This lesson isn’t saved. A free account remembers every lesson you finish.