My issue
Show me your sample output of the problem
My code
/* Write the JS Code to print all even numbers between start and end.*/
const start = 10;
const end = 20;
for (var i = start; i < end; i++) {
if (i % 2 == 0) {
console.log(i+" ");
}
}
Learning course: Web development using JavaScript
Problem Link: Loops Practice Problem in Web development using JavaScript - CodeChef
@aanandhan
u have to do it like this
/* Solution as follows */
const start = 10;
const end = 20;
for (var i = start; i <= end; i++) {
if (i%2 === 0){
console.log(i);
}
}
the sample output of the JavaScript code you selected is:
10
12
14
16
18
This means that the code prints all the even numbers between 10 and 20, excluding 20. You can see the sample output in your browser’s console if you run the code in a web page. You can also use an online tool like [JSFiddle] to test your code and see the output.