JavaScript typing test
JavaScript runs the web, and typing it means braces, semicolons and a lot of dots. console.log has a full stop in the middle, and every program here uses it. The programs are written in modern JavaScript, with let, const, classes and strict === comparisons, so the habits you build carry straight over to real code.
Start the JavaScript typing test
What you'll type in JavaScript
{ }around every block and;at the end of every statement.===for comparisons: three keystrokes where most languages use two..inconsole.log,this.valueandout.push.( )around everyifandforcondition.[ ]for arrays like[50, 30, 70, 20, 40, 60, 80].++and<=in classicforloops.
Example: FizzBuzz in JavaScript
This version keeps each branch on one line, so it's mostly else if, === and console.log again and again: good practice for rhythm.
for (let i = 1; i <= 15; i++) {
if (i % 15 === 0) console.log("FizzBuzz");
else if (i % 3 === 0) console.log("Fizz");
else if (i % 5 === 0) console.log("Buzz");
else console.log(i);
}
Tips for typing JavaScript faster
- Learn
console.log(as one movement. Every program here prints with it. - Type
===without looking. It's the same key three times, so count it in your head the first few times. - Take the semicolon at the end of each line with your right little finger, without lifting your hand from the home row.
All 20 JavaScript programs
Every program is real, working JavaScript. Choose one to start typing it straight away.
Beginner
- Hello, World!Print a greeting.
- Count to fivePrint the numbers 1 to 5.
- Celsius to FahrenheitConvert 100 °C to Fahrenheit.
- Sum a listAdd up 3, 1, 4, 1, 5.
- Find the largestFind the biggest number in a list.
- Count vowelsCount the vowels in "keyboard".
Intermediate
- Reverse a stringTurn "hello" into "olleh".
- FizzBuzzFizz for 3s, Buzz for 5s, 1 to 15.
- FactorialA recursive function, called with 5.
- FibonacciPrint the first ten Fibonacci numbers.
- Greatest common divisorEuclid's algorithm for 48 and 18.
Advanced
- Primes to 20Print every prime up to 20.
- PalindromeCheck whether "racecar" reads the same backwards.
- Word countCount the words in a sentence.
- Bubble sortSort 5, 2, 9, 1, 7 by swapping neighbours.
- Binary searchFind 7 in a sorted list by halving.
Expert
- QuicksortSort a list by partitioning around a pivot.
- Binary search treeBuild a tree, then read the values back in order.
- Shortest path (BFS)Breadth-first search through a small graph.
- N-QueensCount the ways to place 6 queens so none attack.
How the test works
The timer starts on your first key and stops once every character is right. Press Enter for a new line and the indentation is filled in for you. A wrong key shows in red and counts as a mistake; press Backspace to go back and fix it. Your best time for each program is saved in your browser. Read more about how speed and accuracy are calculated, or get tips for typing code faster.