I keep getting an undefined log to my console, it seems to be a pattern when I am using for loops , not sure if I have looped wrong, too far ect. Can you see anything from this?
Hello @willplattt, welcome to the forums! Nothing’s technically wrong; the
undefined comes from how you’re calling the function. Since your
greetAliens function doesn’t explicitly
return anything (as in, you don’t have a
return statement in it), JS defaults to
undefined. Essentially, your function returns
undefined. Therefore, when you log the function call:
Not only do the
console.log() statements within the function run, but the
return value (
undefined) also gets logged.
Thankyou for the help with this!