I have to write this code where only the even numbers are printed from an array. I have gotten then the code to work but it also prints "undefined" and I can't find the problem can anyone please help.
function start(){
var arr = [1,2,3,4,5,6];
var evens = onlyEvens(arr);
println(evens);
}
function onlyEvens(arr)
{
for ( var i = 0; i < arr.length; i++)
{
var cur = arr[i];
if(cur %2==0)
{
println(cur);
}
}
}
برچسب:
نویسنده: آیلین رضوانی
تاريخ: جمعه
20 بهمن
1396 ساعت: 16:05