Quotes
i" is a string's filling, a" the string in its foil; from before the quotes ci" takes the first string on the line, and i' and i` work the same way.
Tuesday, 11:40 a.m. Every item in menu.json gets a description, the line people read on the app before they order. The kitchen sends them over in a chat message; you put them in the strings.
Most lines in menu.json hold two strings: a key and its value. Today you find out which one a quote object takes.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
The quotes are the foil
A string is a burrito whose foil is its two quotes. i" is the filling, the text between them; a" is the string in its foil, quotes included, plus the space after it (or, if there's none, the space before it: the same rule as aw). From anywhere inside the string, ci" replaces the text and keeps the quotes.
toast("Order placed" + suffix, "success");toast("Order placed" + suffix, "success");The next one on the counter
If the cursor is before the first quote on the line, ci" reaches forward and takes the first string it finds. Handy at the start of a line, but in JSON the first string is the key: from the start of { "name": "Birria", … }, ci" changes name, not Birria. To reach the last string on a line, $ then F" puts you on its closing quote.
{ "name": "Birria", "desc": "Beef stew" },{ "name": "Birria", "desc": "Beef stew" },Fill the descriptions
Three empty descriptions, each the last string on its line. Get into each one (or onto one of its quotes) and ci".
This exercise needs a keyboard. Read on, and play it at your computer.
The gap between two burritos
The cursor is on the colon between "desc" and "Beef stew". You press di". What happens?
Off the gap
The kitchen revised two descriptions. The first slip is made for you: di" with the cursor on a colon. Look at what it took, u, then land on a letter of the description and change it to Slow-cooked pork, crisp edges. Then Al Pastor's becomes Pork, pineapple, chilli, from wherever you are.
Stuck? Show a hint
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
Other foils
Single quotes and backticks wrap strings too, and their objects work the same way: ci' for 'Menu', and ci` for a template string in backticks. The filling is everything between the two marks, ${…} and all.
Single quotes and backticks
The app's own strings: a title in single quotes, a template string, and an empty-list message. ci' and ci`; a line's first string can be changed from the start of the line.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
Quotes, from memory
Press the keys. The cursor is inside the string.
Wrong strings
Ten strings with the wrong text across the codebase. The cursor never has to reach the first letter.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
The description pass
12:30. The kitchen's last messages: Garden Veggie's description is still TODO (it should say Beans and peppers), chiken is misspelled, the note becomes Prices before tax., and the allergens line becomes a short Ask us. Four strings, all of them values: never the first string on the line.
Stuck? Show a hint
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
Extra practice optional
The chapter is done. These rounds keep going as long as you like: stop whenever it stops being useful.
Strings, endlessly
Endless wrong strings. Change inside.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.