I have some code where I am able to exit out of the code however whatever is returned is undefined which is weird given if i console.log what I want to return it gives the correct value. Here is my code:
function encryptPass(text, result) {
var a = text.length -1;
var c = text.charCodeAt(a);
if (65 <= c && c <= 90) result += String.fromCharCode((c - 65 + 4) % 26 + 65); // Uppercase
else if (97 <= c && c <= 122) result += String.fromCharCode((c - 97 + 4) % 26 + 97); // Lowercase
else result += text.char; // Copy
if (a == 0) {
console.log(result);
return result;
} else {
encryptPass(text.substr(0, a), result);
}
return;
}
console.log('lemons '+ encryptPass('hello',''));