The following function returns undefined. Why?
function noReturn(arg) {
arg += " bar";
if (arg.length <= 100) noReturn(arg);
else {console.log(arg); return arg;}
}
noReturn("foo");
//logs in the console: "foo bar bar bar bar....", but returns undefined
EDIT: ouch... of course! Thank you for your answers, all of them were perfect.
return noReturn(arg). Without thisreturnexpression the code won't work. But thanks for trying to help!arg. Proof: run this statement:console.log(noReturn('sal')+'foo'). This will output the string"undefinedfoo", instead ofsal bar bar bar....