I can't figure out how to make my code return the first odd number and if there are no odd numbers to return undefined. What am I doing wrong/need to research? The 3 requirements I have are;
1 Return the first odd number in an array of odd numbers
2 Return the first odd number when it is the last number in the array
3 Return undefined when there are no odd numbers
function firstOdd(arg){
for (let i=0; i <= arg.length; i++)
if (i % 2 !== 0) {
return(i)
} else {
return undefined;
}
}
Thank you in advanced for being kind with me.