const findPower = (number, base = 2, power = 0) => {
if (power > 1000) return new Error(`Too large number or it's not a power of ${base}`);
if (number <= 0) return new Error(`Number must be > 0`);
if (number === base ** power) return power;
return findPower(number, base, power + 1)
}
console.log(findPower(8)); // 3
console.log(findPower(16)); // 4
console.log(findPower(1)) // 0
console.log(findPower(3)) // Error
console.log(findPower(-1)) // Error