Ask coding questions

← Back to all posts
stuck on JS Assignment 5: For Loops
dblu803 (0)

// ------- Please begin your work below this line: -------
function exerciseOne(){
// In this exercise, write a simple 'for loop' that starts the variable 'i' at 0 and
// increases i until it reaches 6.
// Fill in the blanks in the parentheses, and then console.log(i) inside of the fo loop
for(i=0 ;i<6 ;i++ ){

}

// Please write your answer in the line above.
}

function exerciseTwo(){
let count = 0;
// In this exercise write your own for loop (you can look at the syntax above).
// It should loop 10 times.
// You are given a variable called: count .
// For each loop reassign count to the current value of count + 1 .

//Please write your answer in the line above.
return count;
}

Answered by malvoliothegood (146) [earned 5 cycles]
View Answer
Commentshotnewtop
malvoliothegood (146)

1)

for(i=0 ;i<6 ;i++ ){
   console.log(i);
}

2)

let count = 0;
for(i=0 ;i<10 ;i++ ){
  count = count + 1;
}