Coding challenges

The essentials every interviewer expects you to write from scratch. Write code in the editor, hit Ctrl+↵ and your solution runs against tests inside a sandboxed web worker.

Beginner

01Reverse a String

Implement reverseString(str) that returns the characters of str in reverse order.

Strings · 4 tests
Beginner

02Palindrome Check

Implement isPalindrome(str) that returns true when str reads the same forwards and backwards.

Strings · 5 tests
Beginner

03FizzBuzz

Implement fizzBuzz(n) that returns an **array** of numbers 1 through n, where multiples of 3 are replaced with the string 'Fizz', multiples of 5 with 'Buzz', and multiples of both with 'FizzBuzz'.

Logic · 4 tests
Beginner

04Find the Maximum

Implement findMax(nums) that returns the largest number in the array. Return null for an empty array.

Arrays · 4 tests
Beginner

05Sum of Numbers

Implement sum(nums) that returns the total of all numbers in the array. An empty array sums to 0.

Arrays · 4 tests
Beginner

06Factorial

Implement factorial(n) returning n! — the product of all integers from 1 to n. By definition, factorial(0) is 1.

Numbers · 4 tests
Beginner

07Fibonacci Number

Implement fib(n) returning the nth Fibonacci number using **0-based indexing**: fib(0)=0, fib(1)=1, fib(2)=1, fib(3)=2…

Numbers · 4 tests
Beginner

08Count Vowels

Implement countVowels(str) counting occurrences of a, e, i, o, u — **case-insensitive**. 'y' doesn't count.

Strings · 4 tests
Beginner

09Capitalize Words

Implement capitalizeWords(sentence) that upper-cases the **first letter of every word** and lower-cases the rest: 'javaScript IS fun' → 'Javascript Is Fun'.

Strings · 4 tests
Beginner

10Remove Duplicates

Implement removeDuplicates(items) that returns a new array keeping only the **first occurrence** of each value, preserving order.

Arrays · 4 tests
Intermediate

11Valid Anagram

Implement isAnagram(a, b) returning true when b is a rearrangement of a — case-insensitive, spaces ignored ('Dormitory' / 'dirty room' are anagrams).

Strings · 4 tests
Intermediate

12Two Sum

Implement twoSum(nums, target) returning the **indices** [i, j] (i < j) of the two numbers adding up to target. Return null when no pair exists. Exactly one pair exists in every passing test.

Arrays · 4 tests
Intermediate

13Chunk an Array

Implement chunk(items, size) splitting the array into subarrays of length size; the last chunk keeps whatever remains.

Arrays · 4 tests
Intermediate

14Flatten One Level

Implement flatten(arr) that merges nested arrays **one level deep** into a single array: [[1,2],[3,[4]]] → [1,2,3,[4]] (inner-nested values stay as arrays).

Arrays · 4 tests