0
For loop in JS
Hi everyone, when I run this for loop in js i'm getting no output. i'm trying to run the input 3 times in a new line then stop. The for loop "Repetition is the mother of learning, the father of action, which makes it the architect of accomplishment." - Zig Ziglar. Inspired by these words, let's create a little program that will output an expression which is given as input, 3 times. Task Complete the code to output the given expression 3 times. Sample Input Learning is fun! Sample Output Learning is fun! Learning is fun! Learning is fun! var expression = readLine(); //your code goes here for (expression; expression<=3; expression++) { console.log(expression + "<br />"); }
6 Answers
+ 7
Logical Error..
for (let I=0; I<3; I++){
console.log(expression);
}
+ 1
var expression = readLine();
//your code goes here
for (i = 1 ; i <=3 ; i++){
console.log(expression);
}
+ 1
var expression = readLine();
//your code goes here
for (let I=0; I<3; I++){
console.log(expression);
}
Good Luck
0
for (let i=1;i<=3;i++){
console.log(expression);
}
/*or
for (let i=0;i<=2;i++){
console.log(expression);
}*/
Sean Taylor
0
for (var value = 0; value <3; value++){
console.log(expression);
}
Reason we're using it because we have to pass a sample input in expression
0
for (var i=1, text= 'learning is fun!' ; i<=3; i++ ){
console.log(text);
}