Practice Exercises
The best way to learn is by doing. Try these exercises to reinforce your understanding.
Exercise 1: Hello, Name!
Create a variable called name with your name,
then print "Hello, [your name]!" to the console.
Exercise 2: Basic Math
Create two variables for numbers, then calculate and print their sum, difference, product, and quotient.
Try it in the playground →Exercise 3: Even or Odd
Write a program that checks if a number is even or odd using the modulo operator (%).
Exercise 4: Countdown Loop
Write a loop that counts down from 10 to 1, then prints "Blast off!".
Try it in the playground →Exercise 5: Sum of Array
Create an array of numbers and use a loop to calculate their total sum.
Try it in the playground →Exercise 6: Grade Calculator
Write a function that takes a test score and returns the letter grade (A, B, C, D, or F).
Try it in the playground →Exercise 7: Find the Max
Write a function that takes an array of numbers and returns the largest one without using Math.max.
Try it in the playground →Exercise 8: Reverse a String
Write a function that takes a string and returns it reversed. "hello" becomes "olleh".
Try it in the playground →Exercise 9: FizzBuzz
Print numbers 1-100. For multiples of 3, print "Fizz". For multiples of 5, print "Buzz". For both, print "FizzBuzz".
Try it in the playground →Pro Tip
Don't worry if you can't solve an exercise right away. Programming is about problem-solving, and struggling is part of learning. Try breaking the problem into smaller steps!