30+ Practice Exercises

Tiny problems sorted by difficulty. Open the playground in another tab and work through them at your own pace.

Easy (1-2 Concepts Each)

  1. FizzBuzz lite — print numbers 1 to 20.
  2. Sum two numbers — write a function add(a, b).
  3. Greet someone — write greet(name) that returns "Hello, NAME!".
  4. Even or odd — return "even" or "odd" given a number.
  5. Larger of two — return whichever of two numbers is bigger.
  6. Count vowels — count vowels in a string.
  7. Reverse a string — return the string backward.
  8. Length of string — without using built-in length.
  9. Is the year a leap year? — divisible by 4, but not by 100 unless also by 400.
  10. Convert °C to °F — formula: F = C * 9/5 + 32.

Medium (3-4 Concepts)

  1. FizzBuzz classic — print 1 to 100, "Fizz" for multiples of 3, "Buzz" for 5, "FizzBuzz" for both.
  2. Sum of an array — without built-in reduce.
  3. Average of an array — sum / length.
  4. Find the largest — maximum value in an array.
  5. Count words — count words in a sentence.
  6. Capitalize first letter of every word.
  7. Remove duplicates from an array.
  8. Filter evens — return only even numbers from a list.
  9. Tip calculator — given bill and percent, return tip and total.
  10. Palindrome check — is the string the same forward and backward?

Harder (Uses 5+ Concepts)

  1. To-do list — array of objects with { task, done }; functions to add, complete, list.
  2. Number guessing game — random target, user guesses, "higher/lower" feedback.
  3. Roman numerals — convert a number to Roman numerals up to 100.
  4. Caesar cipher — shift each letter by N.
  5. Word frequency counter — given a paragraph, return most common words.
  6. Bank balance — start at 0; functions deposit, withdraw (no overdrafts).
  7. Tic-tac-toe board — represent a board, check for winners.
  8. Pig Latin translator — move first letter to end + "ay".
  9. Validate email — does the string have @ and a dot after?
  10. Simple calculator — function that takes two numbers and an operator, returns the result.
  11. Fibonacci sequence — print the first N Fibonacci numbers.
  12. Anagram check — are two strings anagrams of each other?
💡
Approach

Solve each one in your head first. Then write a rough version. Then clean it up. Don't Google a solution until you've been stuck for at least 20 minutes — the stuck time is where learning happens.