Practice JavaScript online
A free JavaScript editor that runs your code in your browser's own JavaScript engine. Write code, press Run, see what console.log prints, and type your answers when prompt() asks. There's nothing to install and no account to make.
Modern JavaScript · free · no sign-up · runs in your browser
JavaScript practice problems for beginners
Each one opens in the editor above as a working program with something left for you to finish.
- problem 1
Greet me
Ask for a name and an age with prompt(), then print one sentence that uses both.
- problem 2
Even or odd
Read a whole number and use the % operator to say whether it's even or odd.
- problem 3
FizzBuzz
Print 1 to 30, but Fizz for multiples of 3, Buzz for multiples of 5, and FizzBuzz for both.
- problem 4
Shopping total
Add up the prices in the array with a loop (or reduce), then print the total.
- problem 5
Longest word
Write a function that returns the longest word in a sentence, and test it.
A free online JavaScript compiler that runs in your browser
- Modern JavaScript: let and const, arrow functions, template literals, classes and array methods
- console.log prints arrays and objects the way Node.js does
- prompt() works: the program pauses and you type your answer in the console
- Errors point to the exact line
- Your code is remembered in your browser, and Share gives you a link
- Starts instantly: JavaScript is built into your browser, so there's nothing to download
JavaScript editor questions
Is this JavaScript editor free?
Yes. It's free, with no sign-up, no ads and no tracking. Your code runs in your own browser and isn't sent anywhere unless you press Share to make a link.
Which version of JavaScript does it run?
The JavaScript engine built into your browser, so the newest language features your browser supports all work. Programs run in strict mode, inside a background worker, so a loop that never ends can't freeze the page.
Does prompt() work?
Yes. When your program calls prompt(), it pauses and you type your answer in the console instead of a pop-up box, then press Enter. Like in a browser, the answer is always text: wrap it in Number() to do math with it.
Can I make web pages here?
This page runs JavaScript programs that print to the console, the way Node.js does. For web pages, open the main editor and make an HTML file: it can use your CSS and JavaScript files by name. The free Build Your First Website course in Courses teaches HTML and CSS from scratch.
Does it work on a Chromebook, iPad or phone?
Yes, in any up-to-date browser: Chrome, Safari, Edge or Firefox, including school Chromebooks. There's nothing to download first.
Is my code saved?
Your code is remembered in your browser, so it's there when you come back on the same device. To keep a copy or send it to someone, press Share for a link, or Copy.
Are there any limits?
A program can run for 10 seconds (time spent waiting for you to type doesn't count), and programs can be up to 20,000 characters. That's plenty for practice problems, school assignments and small projects.
Want a coach while you practice?
HopeCoders teaches JavaScript 1-on-1 for all ages, from first programs to school projects. Every coach is background checked, and sessions happen in person across Greater Los Angeles, from Pasadena, Burbank and Beverly Hills to the South Bay, Long Beach and north Orange County, or online over Zoom.