Code exercises
Some lessons are code exercises: you get one or more files to change and a set of tests that check your work. You write the code in the lesson, run the tests and read the results. Nothing to install.
Run the tests
Section titled “Run the tests”- Read The task.
- Change the code in Your code. Each file has its own text area, named after the file.
- Choose Run tests, or press Ctrl+Enter (Command+Enter on a Mac) while you are in an editor.
- Results lists every test as Passed, Failed or Error, with the message of a failed test, for
example “Expected 3, received 0”. Any text your code printed with
console.logis under Console output.
Open The tests to read the tests themselves. You cannot change them.
Your code, your attempts
Section titled “Your code, your attempts”- Your changes are kept in this browser while you work, so closing the page does not lose them. Start over puts every file back to where it began, after you confirm.
- Each run that ran the tests is saved as an attempt. The lesson shows how many attempts you have made and your best score.
- The topic is marked complete when the exercise’s rule is met, usually when all tests pass.
- It is practice: attempts move your progress, but they do not count towards a certificate.
When something goes wrong
Section titled “When something goes wrong”- Your code could not be built lists the file and line of the problem, for example a missing bracket. Nothing is saved as an attempt.
- The tests took too long means your code probably has a loop that never ends. The run was stopped; fix the loop and run again.
- The code runner could not start means the tests cannot run here right now. You can still read the task and edit your code.
Safety
Section titled “Safety”Your code runs in an isolated area of your browser with no access to the internet, to this page or to your account.
With a keyboard or a screen reader
Section titled “With a keyboard or a screen reader”Everything works with the keyboard. The editors are ordinary text areas: Tab moves on to the next control instead of inserting a tab, so you never get stuck. Results are announced when they are ready, and every result is written out in words, not only shown in colour. Nothing moves when your system asks for reduced motion.