Delete the dead code
The whole of track four against the clock: tour legacy.js with every vertical motion, then cut its last three dead functions with d}.
Friday, 4:00 p.m. Three dead functions are still in legacy.js: the old receipt printer, the 2019 "burrito of the month", and a CSV export nobody ever used. The team wants them gone before the weekend, and they'd like a quick tour of what's left on the way.
One hour, 290 lines, and every way you know to cross a long file.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
The whole book, on one card
The ruler for lines you can see (13j), page numbers for lines you're told (214G, gg, G), paragraph breaks for the next function (} {), half pages for reading (Ctrl-d Ctrl-u), and the open page's top, middle and bottom (H M L). Pick by what you know about where you're going.
// legacy.js — Byte Burrito, 2019–present. Please don't add anything here.// (Everyone has added something here.)const TAX_RATE = 0.0875;const MAX_DISTANCE_KM = 8;const OPEN_HOUR = 11;const CLOSE_HOUR = 23;const RUSH_START = 12;const RUSH_END = 14;function isOpen(now) { const hour = now.getHours(); return hour >= OPEN_HOUR && hour < CLOSE_HOUR;}// legacy.js — Byte Burrito, 2019–present. Please don't add anything here.// (Everyone has added something here.)const TAX_RATE = 0.0875;const MAX_DISTANCE_KM = 8;const OPEN_HOUR = 11;const CLOSE_HOUR = 23;const RUSH_START = 12;const RUSH_END = 14;function isOpen(now) { const hour = now.getHours(); return hour >= OPEN_HOUR && hour < CLOSE_HOUR;}// legacy.js — Byte Burrito, 2019–present. Please don't add anything here.// (Everyone has added something here.)const TAX_RATE = 0.0875;const MAX_DISTANCE_KM = 8;const OPEN_HOUR = 11;const CLOSE_HOUR = 23;const RUSH_START = 12;const RUSH_END = 14;function isOpen(now) { const hour = now.getHours(); return hour >= OPEN_HOUR && hour < CLOSE_HOUR;}// legacy.js — Byte Burrito, 2019–present. Please don't add anything here.// (Everyone has added something here.)const TAX_RATE = 0.0875;const MAX_DISTANCE_KM = 8;const OPEN_HOUR = 11;const CLOSE_HOUR = 23;const RUSH_START = 12;const RUSH_END = 14;function isOpen(now) { const hour = now.getHours(); return hour >= OPEN_HOUR && hour < CLOSE_HOUR;}// legacy.js — Byte Burrito, 2019–present. Please don't add anything here.// (Everyone has added something here.)const TAX_RATE = 0.0875;const MAX_DISTANCE_KM = 8;const OPEN_HOUR = 11;const CLOSE_HOUR = 23;const RUSH_START = 12;const RUSH_END = 14;function isOpen(now) { const hour = now.getHours(); return hour >= OPEN_HOUR && hour < CLOSE_HOUR;}// legacy.js — Byte Burrito, 2019–present. Please don't add anything here.// (Everyone has added something here.)const TAX_RATE = 0.0875;const MAX_DISTANCE_KM = 8;const OPEN_HOUR = 11;const CLOSE_HOUR = 23;const RUSH_START = 12;const RUSH_END = 14;function isOpen(now) { const hour = now.getHours(); return hour >= OPEN_HOUR && hour < CLOSE_HOUR;}// legacy.js — Byte Burrito, 2019–present. Please don't add anything here.// (Everyone has added something here.)const TAX_RATE = 0.0875;const MAX_DISTANCE_KM = 8;const OPEN_HOUR = 11;const CLOSE_HOUR = 23;const RUSH_START = 12;const RUSH_END = 14;function isOpen(now) { const hour = now.getHours(); return hour >= OPEN_HOUR && hour < CLOSE_HOUR;}Stage 1 · The tour
4:05. Before anything is deleted, the team wants a look at six functions that stay, so nobody cuts the wrong one. They ask in their own order, all over the file; the goal bar gives each line number and why it stays. Any vertical motion.
This exercise needs a keyboard. Read on, and play it at your computer.
Stage 2 · Cut the dead
4:40. The three dead functions, top to bottom: the old receipt printer, the burrito of the month and the CSV export. Cut each one, comment and all, and leave one blank line between the functions around it. Any route you like.
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.
The whole track, from memory
Seven situations from this week.
Extra practice optional
The chapter is done. These rounds keep going as long as you like: stop whenever it stops being useful.
The long book
Endless stops anywhere in legacy.js, with every vertical motion allowed.
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.