typescript · 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 have spaces and cannot start with a digit. Capitals matter, so pet and Pet are two different boxes.
Good names say what is inside. x tells you nothing, but petName tells you everything. Your future self will thank you.
Need more than one word? Squash them together and give each new word a capital letter, like bestFriend. This is called , because the capitals stick up like humps.
let bestFriend: string = "Priya";
console.log("My best friend is " + bestFriend); TypeScript does not mind what your names mean, but people reading your code do.
guess first
Two boxes, nearly the same name. What shows?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
let score: number = 5;
let Score: number = 99;
console.log(score);
your turn
Your turn. Name the boxes.
Choose a camelCase name for each box, like dogName. Use the same two names again in the last line, then press run.
fix it
This name breaks the rules. Can you fix it?
- The error points at line 1. Look closely at the name of the box.
- A name cannot have a space in it. TypeScript reads favourite as the name, then gets lost.
- Write favouriteColour in camelCase on both lines, then press run.
nailed it
you gave your boxes great names. :D
- Names use letters, digits,
_and$, with no spaces. - A name cannot start with a digit, and capitals matter.
- Use camelCase names that say what is inside.
new words in your collection
- camelCase
This lesson isn’t saved. A free account remembers every lesson you finish.