Skip to content

Instantly share code, notes, and snippets.

@AlvisonHunterArnuero
Created April 12, 2024 23:23
Show Gist options
  • Save AlvisonHunterArnuero/615d2fa20f986146cd095e00b018e6d1 to your computer and use it in GitHub Desktop.
Save AlvisonHunterArnuero/615d2fa20f986146cd095e00b018e6d1 to your computer and use it in GitHub Desktop.
// 11 - Bouncing Ball | https://www.codewars.com/kata/5a40c250c5e284a76400008c
const bouncingBall = (initial, proportion) => {
let totalBounces = 0;
while (initial > 1) {
totalBounces++;
initial *= proportion;
}
return totalBounces;
}
console.log(bouncingBall(2, 0.5)); // 1
console.log(bouncingBall(4, 0.5)); // 2
console.log(bouncingBall(10, 0.1)); // 1
console.log(bouncingBall(100, 0.1)); // 2
console.log(bouncingBall(9, 0.3)); // 2
console.log(bouncingBall(30, 0.3)); // 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment