function bouncingBall(h, bounce, window) {
if (h <= 0 || bounce <= 0 || bounce >= 1 || window >= h) return -1;
 
let count = 1; // первый раз видим при падении
let currentHeight = h * bounce;
 
while (currentHeight > window) {
count += 2;
currentHeight *= bounce;
}
 
return count;
}
 
console.log(bouncingBall(3, 1, 1.5));
console.log(bouncingBall(3.0, 0.66, 1.5));
console.log(bouncingBall(30.0, 0.66, 1.5));
Code will run automatically after changes.
Code runs in an isolated environment.