"use strict";
let moves = 0;
function Mormons(startingNumber, reach, target) {
if (startingNumber >= target) return moves;
startingNumber += startingNumber * reach;
moves++;
//console.log(startingNumber, moves);
Mormons(startingNumber, reach, target);
}
console.log(Mormons(40, 2, 121));
This case should return 2 and if you remove the comment, it prints 2 on the second iteration, also it returns 0 if target is less than or equal to startingNumber, but with any other case it returns undefined. I'm new to JavaScript btw.