Here is my code
function consec(string) {
for (let letter of string) {
console.log(letter);
}
}
console.log(consec("zoo"));
the result is
"z"
"o"
"o"
undefined
This is the link of my code. Please feel free to correct. (It's my first to ask question through SO, I appreciate any advices :))
undefinedis the return value ofconsec()function. Since you are not returing anything fromconsec(), it is displayingundefined.undefinedhere is the return value from the function. The characters are logged in the function, and "undefined" is logged from the.logwhich callsconsecbecause the function doesn't return anything.