LOCK.IN Intermediate: make the page do something
You finish with an interactive page wired to real data.
What is inside
All 6 chapters
1Values and types
Tell what kind of thing a value is before the code runs.
2Control flow and functions
Give a piece of logic one name, one input and one job.
3Arrays and objects
Keep many values in order, and a record in named fields.
4The DOM
Find a node in the page and change it from code.
5Events and state
Keep one value as the truth and redraw from it.
6Fetching and shipping
Read data from somewhere that can fail, and say so on screen.
Quests and Challenges
- quizRead a record without guessing+15 XP
- repoShip a small stateful page+10 XP
- bank soalRequests and their failures+10 XP
Chapter 1: Values and types
Read the first chapter
Twelve and "twelve" are different things
A value is a piece of data and a type is what kind it is. 12 is a number you can add to. "12" is a string of two characters that happen to be digits: and + will join it to another string instead of adding it.
console.log(12 + 5);console.log("12" + "5");console.log("12" + 5);console.log(typeof 12, typeof "12");The fourth line prints number string. typeof answers the question the whole chapter is about, and it costs less than a guess.
What `+` does to a mix
When one side of + is a string, JavaScript turns the other side into a string and joins them. Other arithmetic operators go the other way: they try to make a number.
console.log("3" * 4);console.log("3" + 4);console.log(3 + 4 + "!");console.log("Items: " + 3 + 4);console.log(Number("3") + 4);"Items: " + 3 + 4 prints Items: 34, not Items: 7, because the join happens left to right. Group the sum in brackets or convert with Number() before you join.
The other 5 chapters
Every interactive code checkpoint, the PDF edition, Quests and Socratic AI.
