HCDD 411
1 / 21

JavaScript
Practice Problems

HCDD 411 — 20 Exercises covering everything from class

5
Easy

Lots of guidance

5
Easy–Medium

Good hints

5
Medium

Some hints

5
Medium–Hard

You're on your own

🎯 How to use this: Write your code in each editor and press Run Code to see the output. Use arrow keys or the buttons below to navigate between problems.
⭐ Easy — Problem 1 of 20

Say Hello to the World

🎯 Your Challenge:
Print the message "Hello, World!" to the console.

Step-by-step instructions:

💡 Reminder: You can use either single quotes '...' or double quotes "..." around your text.
✅ Expected Output: Hello, World!
YOUR CODE
Output:
⭐ Easy — Problem 2 of 20

Variables About You

🎯 Your Challenge:
Create three variables to store information about a person, then log each one.

Step-by-step instructions:

💡 Syntax reminder: let variableName = value; — use let to declare your variables.
✅ Example Output (your values may differ): Alice 22 true
YOUR CODE
Output:
⭐ Easy — Problem 3 of 20

Positive or Negative?

🎯 Your Challenge:
Check whether a number is positive, negative, or zero, and print the result.

Step-by-step instructions:

💡 Operators: Use > for "greater than" and < for "less than".
YOUR CODE
Output:
⭐ Easy — Problem 4 of 20

Count to Ten

🎯 Your Challenge:
Use a for loop to print the numbers 1 through 10, one per line.

Step-by-step instructions:

💡 Template: for (let i = 1; i <= 10; i++) { ... }
✅ Expected Output: 1 2 3 ... (up to 10)
YOUR CODE
Output:
⭐ Easy — Problem 5 of 20

Add Two Numbers

🎯 Your Challenge:
Write a function called add that takes two numbers and returns their sum. Then call it and print the result.

Step-by-step instructions:

💡 Remember: return sends a value back. Without it, the function returns undefined.
✅ Expected Output: 8 15
YOUR CODE
Output:
🔵 Easy–Medium — Problem 6 of 20

Build a Student Object

🎯 Your Challenge:
Create an object representing a student with specific properties, then access and update them.

Instructions:

💡 Hint: Objects look like: let obj = { key: value, key2: value2 };
YOUR CODE
Output:
🔵 Easy–Medium — Problem 7 of 20

Fruits Array

🎯 Your Challenge:
Create an array of fruits and practice adding and removing items using array methods.

Instructions:

💡 Hint: push() / unshift() return the new length. pop() / shift() return the removed item.
YOUR CODE
Output:
🔵 Easy–Medium — Problem 8 of 20

Grade Classifier

🎯 Your Challenge:
Write a function that takes a numeric score and returns a letter grade.

Instructions:

💡 Hint: Use if / else if / else. Check from the highest score down so the conditions don't overlap.
YOUR CODE
Output:
🔵 Easy–Medium — Problem 9 of 20

Countdown with a While Loop

🎯 Your Challenge:
Use a while loop to count down from 10 to 1, then print "Blast off!".

Instructions:

💡 Warning: Don't forget to decrement count inside the loop — otherwise it will run forever!
YOUR CODE
Output:
🔵 Easy–Medium — Problem 10 of 20

forEach – Print with Index

🎯 Your Challenge:
Use forEach to iterate over an array of colors and print each one with its index number.

Instructions:

💡 Hint: forEach passes the element first, the index second: arr.forEach(function(element, index) { ... })
YOUR CODE
Output:
🟡 Medium — Problem 11 of 20

Double With map()

🎯 Your Challenge:
Use the map() method to create a new array where every number is doubled.

Instructions:

🔑 Hint: map() takes a function that receives each element and returns the new value for that position.
YOUR CODE
Output:
🟡 Medium — Problem 12 of 20

Filter the Evens

🎯 Your Challenge:
Use filter() to extract only even numbers from an array.

Instructions:

🔑 Hint: % is the modulo operator. n % 2 === 0 is true when n is even.
YOUR CODE
Output:
🟡 Medium — Problem 13 of 20

Object with a Method

🎯 Your Challenge:
Create an object that has both data properties and a method (a function inside an object).

Instructions:

🔑 Hint: Inside a method, use this.width to refer to the object's own properties.
YOUR CODE
Output:
🟡 Medium — Problem 14 of 20

Arrow Functions

🎯 Your Challenge:
Rewrite two functions using the ES6 arrow function syntax.

Instructions:

🔑 Hint: Arrow syntax: const funcName = (param) => expression;. For a one-liner you can drop the curly braces and return keyword.
YOUR CODE
Output:
🟡 Medium — Problem 15 of 20

some() and every()

🎯 Your Challenge:
Use some() and every() to check conditions across an array of scores.

Instructions:

🔑 Hint: every() returns true only if the condition is true for all elements. some() returns true if at least one element satisfies the condition.
YOUR CODE
Output:
🔴 Medium–Hard — Problem 16 of 20

Chain map() and filter()

🎯 Your Challenge:
From an array of numbers, first double them all, then keep only the ones greater than 10. Do it in one chained expression.

Instructions:

YOUR CODE
Output:
🔴 Medium–Hard — Problem 17 of 20

Array of Objects + forEach

🎯 Your Challenge:
You have an array of student objects. Use forEach to print a formatted summary for each student, and use filter to get only students with a GPA above 3.5.

Instructions:

YOUR CODE
Output:
🔴 Medium–Hard — Problem 18 of 20

Build a Class

🎯 Your Challenge:
Create a BankAccount class with a balance, and methods to deposit, withdraw, and check the balance.

Instructions:

YOUR CODE
Output:
🔴 Medium–Hard — Problem 19 of 20

Word Frequency Counter

🎯 Your Challenge:
Given an array of words, write a function that returns an object showing how many times each word appears.

Instructions:

YOUR CODE
Output:
🔴 Medium–Hard — Problem 20 of 20

Student Roster Manager

🎯 Your Challenge:
Build a Roster class that manages a list of students. It should support adding students, removing them by name, and computing the average GPA of the class.

Instructions:

YOUR CODE
Output: