When I run the below JS, the console correctly logs a as string: "foo", but then the return value is undefined. typeof() also says it's a string. There is no change from line 5 to 6 (the console.log and the return), so how can this spontaneously become undefined?
let a = "foo";
let c = 0;
function test() {
if (c === 5) {
console.log(a);
return a;
} else {
c++;
test();
}
}