+ 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 ;/
19 Respostas
+ 8
// Your code here
for(i = 20; i <= 120; i += 20){
console.log(i)
}
+ 3
Mateusz Wielgat works fine just initialise the pages variable with a value 0 .
var pages=0;
+ 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);
}
+ 1
Replace pages*=i with pages+=20;
+ 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
+ 1
See code below:
var min = 6;
var pages = 0;
for (i = 1; i <= min; i++) {
pages +=20
console.log(pages) }
+ 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)
}
0
Yes work. Thank you but I dont understand how this work š¶
0
var min = 6;
var pages = 0;
for (i = 1; i <= min; i++) {
pages=20*i;
console.log(pages*1)
}
0
var a = [20,40,60,80,100,120]
for (i=0;i<a.length;i++) {
console.log(a[i]);
}
0
var min=6;
var page=20;
for (i=1; i<=min; i++){
page =i*20
console.log(page)
}
0
for (i = 20, text=""; i<=120; i+=20){
text = i;
console.log(i);
}
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);
}
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++))
}
0
for (i = 20 ; i <= 120 ; i+=20 ){
console.log(i);
}
0
let pages = 20;
for(i=1; i<=6; i++ ){
console.log(pages);
pages +=20;
}
0
// Your code here
for(i = 20; i <= 120; i += 20){
console.log(i)
}
Good Luck
0
var pageperminute = 20;
var minute = 6;
for (i=1; i<=minute; i++ )
{console.log( pageperminute * i)};
- 1
its wrong