Content
Build a shopping cart system using array methods.
Requirements:
['laptop', 'mouse', 'keyboard', 'monitor']push()pop()includes()indexOf()slice()Bonus: Create a second array of prices that corresponds to each product. Calculate the total price of items in the cart.
Given an array of numbers, find and remove specific values.
Requirements:
[5, 10, 15, 20, 25, 30, 35, 40, 45, 50]slice() to create a new array containing only numbers less than 25slice() with negative indicesChallenge: Create a function that takes an array and a target number, and returns true if the target exists, false otherwise. Don't use includes() - implement it yourself with a loop.
The Collatz conjecture is a famous unsolved problem in mathematics. The rules are simple:
Example: 10 → 5 → 16 → 8 → 4 → 2 → 1 (6 steps)
Requirements:
while loop that performs the Collatz sequence starting from any numberChallenge: Find the first number under 100 that takes exactly 20 steps to reach 1. Use a for loop to test numbers 1-100.
Learn more:
Create a restaurant menu system using objects and loops.
Requirements:
name, price, category, vegetarianfor...of loop to print all menu itemsfor...of loop to calculate the total price if you ordered everythingObject.keys() to list all properties of one menu itemBonus: Use destructuring to extract name and price from a menu item in a single line.
Challenge: Write a function that takes the menu array and returns only vegetarian items. Use a loop and push() to build the filtered array.
The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 **
