JavaScript practice
Practice JavaScript online: 10 exercises, graded problems and a playground
JavaScript needs no download at all: your browser already contains a complete JavaScript engine, and that is what runs your code here — inside a sandboxed worker, cut off from the page and the network. The exercises use console.log and a readline() helper for input, so they read like the plain scripts you would run with Node, not like web-page code.
- checked exercises
- 10
- graded problems
- 3
- lessons
- 9
- cheat sheet
- 1
JavaScript practice exercises
How the path works →In order, each one introducing a single new idea. Press Run to check your answer; hints open one at a time.
- Hello, Out Loudconsole.log() puts text on the screen
- Name Tagconst gives a value a name you can use again
- Party PlannerJavaScript does arithmetic, and whole-number division needs Math.floor and %
- Umbrella or Notif/else chooses between two outcomes
- Countdowna for loop repeats an action
- The Clapping Gamean if inside a for, decided again on every pass
- The Scoreboardtemplate literals build text with values inside it
- Packing Listan array holds several values in order, and for...of walks through them
- Rainfall Weeka value declared with let above a loop carries a running total from pass to pass
- The Cafe Ticketassembling a complete program out of parts you already know
Graded JavaScript practice problems
Checked against hidden test cases — the step up from the exercises. Some are debugging labs: the program is already broken, and the job is to find out why.
JavaScript lessons behind the practice
All lessons →- JavaScript Printing and OutputLearn what console.log really does in JavaScript - string concatenation with +, template literals, printing multiple values, and the escape sequences you will use constantly.
- JavaScript Variables and Data TypesUnderstand let and const, JavaScript's primitive types, and how typeof, undefined, and null behave when you check and convert values.
- JavaScript Arithmetic and NumbersHow JavaScript does math - why there is only one number type, what the remainder operator really answers, powers, the Math object, and why 0.1 + 0.2 is not 0.3.
- JavaScript StringsLearn how JavaScript strings are created, why they are immutable, how indexing and slicing work, and the string methods you will use most, including padStart and padEnd for alignment.
- JavaScript Conditionals: if, else if, and elseLearn how JavaScript makes decisions with if, else if, and else, the difference between === and ==, truthiness, and the ternary operator.
- JavaScript ArraysLearn how JavaScript arrays store ordered, changeable lists of values, and how to create, access, modify, search, sort, and transform them with push, map, and filter.
- JavaScript ObjectsLearn how JavaScript objects pair keys with values, read them safely with optional chaining, add, update, and delete properties, loop with Object.entries, and why lookups are fast.
- JavaScript For Loops and IterationLearn JavaScript loops from the ground up - the classic for loop, for...of, the forEach array method, getting both index and value with entries, and steering a loop with break and continue.
- JavaScript Functions: Declaring, Calling, and ReturningLearn JavaScript functions from scratch - function declarations, arrow functions, parameters and default values, return values, and local versus global scope.
JavaScript cheat sheet
Everyday syntax on one page, for when you remember the idea but not the spelling.
Coding interview questions
Original questions with full model answers, for when the practice is going somewhere specific.
Questions people ask
- Which JavaScript engine runs my code?
- Your browser's own engine — V8 in Chrome and Edge, SpiderMonkey in Firefox, JavaScriptCore in Safari. Nothing is downloaded, which is why the JavaScript exercises start instantly.
- How does reading input work when there is no Node.js?
- The sandbox provides a readline() function that returns the next line from the input box beside the editor. It is the one addition to the language you will find here, and the exercises say so wherever they use it.
- Is console.log the same as in the browser console?
- It prints to the output panel instead of the developer console, and objects are shown as text rather than expandable trees, but the values are the same. That is what the exercises check: the exact lines your program prints.
- What comes after the beginner exercises?
- After the 10 exercises there are graded practice problems checked against hidden tests, lessons on the ideas behind them, and the TypeScript path if you want types on top of the JavaScript you already know.
Practise another language
The same kind of practice hub exists for Python, TypeScript, Java, C++, C, C#, Go, PHP, Ruby, SQL, R and Bash & the Shell.