-1
function exibePar(n1,n2){
while(n1<=n2){
if((n1%2)==0){
var par = n1
}
n1++
}
}
console.log(exibePar(0,20))
My code is not showing all pairs it only shows 0.
What is "bold text"?
– Sam
mistake my sorry
– Eduardo Candido
What is the purpose of this function? Display the first even number? Assemble a list of even numbers in the range?
– bfavaretto
set up a list of even numbers in the range
– Eduardo Candido
The.log console will not return while values, or will?!
– Sam
Then start by creating an empty list (array) before while! And inside, insert something into that list. You have created a variable that changes value as you go through the range.
– bfavaretto
I don’t know I thought I would
– Eduardo Candido
The console.log is to show the end result of an action, and not loop, I imagine.
– Sam
Aaaah yes vlw help
– Eduardo Candido
Do the q @bfavaretto said, create an array and add the values with push. Now this
(n1%2)==0
could be thisn1%2==0
– Sam
can give me an idea of how to do this if it’s no bother
– Eduardo Candido
Before function:
var pares = [];
... within theif
:pares.push(par);
– Sam
Thanks now I’ll get
– Eduardo Candido