Iterations JS Homework
Practice problems for iterations
- 3.8 Iterations Homework 🔄
- 📌 Problem 1: Fill in the Blank 📝
- 🚀 Problem 2: Create Your Own Loop
3.8 Iterations Homework 🔄
Complete the following problems to practice your iteration skills!
📌 Problem 1: Fill in the Blank 📝
Complete the code below to make it print all numbers from 1 to 10.
Expected output: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
%%javascript
// Fill in the blanks to complete the loop
for (let i = 1; i <= 10; i++) {
console.log(i);
}
<IPython.core.display.Javascript object>
🚀 Problem 2: Create Your Own Loop
Write a program that uses a while
loop to print "Hello!" 5 times.
Expected output:
Hello!
Hello!
Hello!
Hello!
Hello!
%%javascript
// YOUR CODE HERE
// Submit through the Link in Announcements
let count = 0;
while (count < 5) {
console.log("Hello!");
count++;
}
<IPython.core.display.Javascript object>