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 />"); }

5th Oct 2021, 1:37 PM
Sean Taylor
Sean Taylor - avatar
6 Réponses
+ 7
Logical Error.. for (let I=0; I<3; I++){ console.log(expression); }
5th Oct 2021, 1:42 PM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
var expression = readLine(); //your code goes here for (i = 1 ; i <=3 ; i++){ console.log(expression); }
15th Nov 2021, 11:22 AM
MD RAKIBUL HASSAN NAYON
MD RAKIBUL HASSAN NAYON - avatar
+ 1
var expression = readLine(); //your code goes here for (let I=0; I<3; I++){ console.log(expression); } Good Luck
25th Jan 2022, 8:05 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
0
for (let i=1;i<=3;i++){ console.log(expression); } /*or for (let i=0;i<=2;i++){ console.log(expression); }*/ Sean Taylor
9th Oct 2021, 2:02 PM
Md Imraj Hossain
Md Imraj Hossain - avatar
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
4th Aug 2022, 11:59 AM
Hamad
Hamad - avatar
0
for (var i=1, text= 'learning is fun!' ; i<=3; i++ ){ console.log(text); }
20th Oct 2022, 5:44 AM
Oumar Ouattara
Oumar Ouattara - avatar