Words and WORDs
iw and aw are a word and a word in its foil; iW and aW are the kangaroo's WORD, everything between spaces, so ciW replaces a whole dotted path.
Tuesday, 10:25 a.m. The review on the loader is back: "Too many dotted paths. `data.menu.items` is just `data.menu` now; please shorten them." There are nine across the loader, the kitchen display and the menu page, and you'll rarely have the cursor on the first letter of one.
ciw takes data, or menu, or one dot. You want the whole path, in one bite.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
The smallest burrito
You already know the word objects: iw is the word, aw is the word in its foil, the space beside it. ciw renames a word from anywhere inside it; daw deletes it without leaving a double space. The same pair works with any verb: yiw copies the word under the cursor.
The kangaroo’s WORD
Remember the kangaroo from day one? W leaps from space to space, clearing dots and brackets in one go. Its object is the WORD: iW is everything between two spaces, so with the cursor anywhere in data.menu.items, ciW replaces the whole path. aW is the same WORD in its foil, with the space beside it.
return data.menu.items ?? [];return data.menu.items ?? [];return data.menu.items ?? [];return data.menu.items ?? [];One bite
Three dotted paths on the kitchen display to shorten. ciW from anywhere inside each one, and type the short name.
This exercise needs a keyboard. Read on, and play it at your computer.
Where does the leap end?
The cursor is in items. You press ciW, type list, and Esc. What does the line say?
Spaced or glued?
The last three paths in menu-page.ts: data.menu.items becomes data.menu, and data.open.hours becomes data.open. Only one of them stands between spaces. Before each one, look at what touches it: ciW where it's spaces on both sides, something else where a bracket, comma or semicolon is stuck to it.
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.
Dotted names
Dotted names replaced by junk. Put each one back with ciW.
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.
Words and WORDs, from memory
Press the keys. The cursor is somewhere inside.
Small and large
Misspelled words, doubled words and wrong dotted names, ten of them. Word or WORD: pick the size that fits.
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 loader review
10:50. Five comments on menu-loader.ts, top to bottom: three dotted paths lose their last part (data.menu.items becomes data.menu, and so on; the settings one becomes data.currency), a doubled const, and currency, listed twice in the export. Look at what each one touches, then pick word or WORD, inside or around.
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.
Words, endlessly
Endless words and WORDs to fix across the codebase.
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.