EDIT: Turns out I had filtering enabled which removed the console.log outputs from Chrome's console. I disabled it and my issue was fixed.
I have very basic experience with JS and am attempting to translate my Java code into JS. The issue I'm having is that when running my code within Chrome's console, I am being returned "undefined". However, when running on online compilers such as codepad.remoteinterview.io or JSBin.com, their consoles are printing what I need it to. Is this a problem on my end, whether or not so, is there a way I can fix this? Thank you.
function writeOut(i) {
if (i !== 0)
return "(1 / " + i + ") + "+writeOut(i-1);
else // base case
return "";
}
function sum(i) {
if (i === 1) // base case
return 1;
else
return 1 / i + sum(i - 1);
}
for (var i = 1; i <= 10; i++) {
console.log("(1 / " + i + "): " + (writeOut(i)) + "| Sum: " + sum(i));
}