What will be the output of the following recursive function?
function countVowels(str) {
if (str === "") {
return 0;
}
let firstChar = str.charAt(0).toLowerCase();
let remainingStr = str.substr(1);
if (firstChar === "a" || firstChar === "e" || firstChar === "i" || firstChar === "o" || firstChar === "u") {
return 1 + countVowels(remainingStr);
}
return countVowels(remainingStr);
}
console.log(countVowels("Hello World"));