Ask coding questions

← Back to all posts
3
JS Assignment 5: For Loops Question
silverflag22 (3)

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;
}

Need help answering these two exercises, thank yall!

Commentshotnewtop
1
mwilki7 (130)

Would you be able to show us what you've got so far?

exerciseOne() looks just about finished, you just need to:
// Fill in the blanks in the parentheses, and then console.log(i) inside of the for loop

exerciseTwo() shoud look very similar to exerciseOne() with similar for loop conditions (but different!)

then figure out how to:
// For each loop reassign count to the current value of count + 1

1
MATTHEWBECHTEL (121)

I don’t do JavaScript.

1
mwilki7 (130)

@MATTHEWBECHTEL Many languages have similar logic flow.
Would you be able to give a hint in the language you're comfortable with?