Reading & walkthrough: not startedGuided practice: not started
Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.
Rob’s comic strip · Final JavaScript challenges
ORIGINAL WALKTHROUGH · 12:43
Watch with Rob.
Pause whenever you want to try a change. You can return to the lesson at any time.
You are signed in, but video access needs attention. Check your account access. Your saved work is kept.
Video walkthroughs are included with an active Code Zone membership. The written lesson and practice are free.
Choose Load this code into the editor beside an example, then edit and Run code here. Predict what will print before running it. This is an exploration workspace, so there is no pass/fail challenge. Its saved work stays separate from the next practice activity.
Load an example, edit it and run it. Word wrap is enabled.
Your check results
Work in VS Code instead
Copy the starter into a file named practice.js in VS Code. If Node.js is installed, open the terminal in that folder and run node practice.js. Compare the output with the task above. Automated challenge checks are available in the browser editor.
Code example
example.jsjavascript · example
const words = "I am a coding ninja".split(" ");for (const word of words) { console.log(word + ": " + word.length);}
Open the code-along notes
Inspect the words and their lengths
The original challenge asks for the longest word, returning the first one if several words share the greatest length. In the original phrase, coding has six letters and ninja has five.
Run this length inventory, then trace a separate candidate as you visit I, am, a, coding and ninja. The candidate should change to I, then am, then coding; it should stay coding at ninja.
Inspect the words and their lengths
example.jsjavascript · example
const words = "I am a coding ninja".split(" ");for (const word of words) { console.log(word + ": " + word.length);}
A second input tests the tie rule
For red sun, both lengths are 3. Keep red because it appears first. Use this case to check the comparison rather than assuming one passing example proves the whole function.
The original assignment accepted a JSFiddle or GitHub URL. Here, signed-in learners can submit their code directly for instructor review. The separate workspace starts with the original phrase and a runnable function stub.