+ 1

Pages per minute (The loop) js.

The printer prints 20 pages per minute. Write a program that will output to the console how many pages will be printed each minute over the course of 6 minutes. Output 20 40 60 80 100 120 My code: var min = 6; var pages = 20; for (i = 1; i <= min; i++) { pages *= i console.log(pages) } I have no idea how to do it ;/

14th Jan 2021, 11:16 PM
Mateusz Wielgat
Mateusz Wielgat - avatar
19 ответов
+ 8
// Your code here for(i = 20; i <= 120; i += 20){ console.log(i) }
12th Apr 2021, 2:44 AM
Osama
Osama - avatar
+ 3
Mateusz Wielgat works fine just initialise the pages variable with a value 0 . var pages=0;
14th Jan 2021, 11:43 PM
Abhay
Abhay - avatar
+ 2
A possible solution, everything integrated in the for loop to make it clean: for (var minutes = 1; minutes <=6; minutes++) { var pages = 20*minutes console.log(pages); }
6th Sep 2021, 9:42 AM
Xavier
+ 1
Replace pages*=i with pages+=20;
14th Jan 2021, 11:24 PM
Abhay
Abhay - avatar
+ 1
var pageperminute = 1; var pages = 20; var min = 6; for (i=1; i<=min; i+=1 ){console.log(pageperminute = pages * i)}; Output 20 40 60 80 100 120
19th Mar 2021, 9:07 AM
Abdelhamid Lahbouch
Abdelhamid Lahbouch - avatar
+ 1
See code below: var min = 6; var pages = 0; for (i = 1; i <= min; i++) { pages +=20 console.log(pages) }
14th Apr 2021, 9:05 PM
Leonard Baker
Leonard Baker - avatar
+ 1
pages = 20 // 20 pages in min //(i < 7) 6 min of printing for (i= 1; i <7; i += 1){ sum = pages * i console.log(sum) }
2nd Sep 2021, 5:34 PM
Ali Bahaeldin Makkawi
Ali Bahaeldin Makkawi - avatar
0
Yes work. Thank you but I dont understand how this work 😶
14th Jan 2021, 11:54 PM
Mateusz Wielgat
Mateusz Wielgat - avatar
0
var min = 6; var pages = 0; for (i = 1; i <= min; i++) { pages=20*i; console.log(pages*1) }
6th May 2021, 11:25 AM
Ashok Swami
Ashok Swami - avatar
0
var a = [20,40,60,80,100,120] for (i=0;i<a.length;i++) { console.log(a[i]); }
11th May 2021, 2:47 PM
Danut
Danut - avatar
0
var min=6; var page=20; for (i=1; i<=min; i++){ page =i*20 console.log(page) }
23rd Jun 2021, 7:41 AM
Limoobit Ui
Limoobit Ui - avatar
0
for (i = 20, text=""; i<=120; i+=20){ text = i; console.log(i); }
26th Aug 2021, 1:34 PM
MD RAKIBUL HASSAN NAYON
MD RAKIBUL HASSAN NAYON - avatar
0
/* First, we need to declare variables names: - variable "pagesPerMin": to assign a value prints pages per minute - variable "numberOfPages": to assign a number of printed pages - then, use For loop to calculate: how many pages were printed after 6 minutes */ var pagesPerMin = 20; var numberOfPages; for (min = 1; min <= 6; min++){ numberOfPages = pagesPerMin * min; console.log(numberOfPages); }
21st Sep 2021, 3:27 AM
WAHAB YOUSIF
WAHAB YOUSIF - avatar
0
My solution, and I think it’s quite good.😀 var pagesPerMinutes = 20 var minutesOfPrint = 1 for(var i=0; i < 6; i++) { console.log(pagesPerMinutes * (minutesOfPrint++)) }
6th Oct 2021, 10:51 AM
Liangyong Peng
Liangyong Peng - avatar
0
for (i = 20 ; i <= 120 ; i+=20 ){ console.log(i); }
15th Nov 2021, 11:34 AM
MD RAKIBUL HASSAN NAYON
MD RAKIBUL HASSAN NAYON - avatar
0
let pages = 20; for(i=1; i<=6; i++ ){ console.log(pages); pages +=20; }
20th Jan 2022, 11:44 PM
Arturo Hermida
Arturo Hermida - avatar
0
// Your code here for(i = 20; i <= 120; i += 20){ console.log(i) } Good Luck
25th Jan 2022, 8:06 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
0
var pageperminute = 20; var minute = 6; for (i=1; i<=minute; i++ ) {console.log( pageperminute * i)};
2nd Mar 2022, 1:26 AM
Ruso olea
- 1
its wrong
14th Jan 2021, 11:31 PM
Mateusz Wielgat
Mateusz Wielgat - avatar