0
0
Javascriptprogramming~30 mins

Nested loops in Javascript - Mini Project: Build & Apply

Choose your learning style9 modes available
Nested loops
📋 What You'll Learn
💡 Why This Matters
🌍 Real World
Nested loops are useful when you want to check every combination of two sets of things, like seating guests at tables or matching products with colors.
💼 Career
Understanding nested loops is important for jobs involving data processing, game development, or any task that requires comparing or combining multiple lists.
Progress0 / 4 steps
1
Create the tables array
Create an array called tables with these exact values: 'Table 1', 'Table 2', and 'Table 3'.
Javascript
Need a hint?
Use square brackets [] to create an array and separate values with commas.
2
Create the guests array
Create an array called guests with these exact values: 'Alice', 'Bob', and 'Charlie'.
Javascript
Need a hint?
Use the same array syntax as before to create the guests array.
3
Use nested loops to pair guests with tables
Use a nested for loop where the outer loop uses the variable table to go through tables and the inner loop uses the variable guest to go through guests.
Javascript
Need a hint?
Use for (const variable of array) syntax for each loop.
4
Print the seating assignments
Inside the inner loop, print the string `${guest} sits at ${table}` using console.log.
Javascript
Need a hint?
Use console.log with a template string to print the message.