← Back to challenges

Free Throw Probability

JavaScriptHardmath

Instructions

What's the probability of someone making a certain amount of free throws in a row given their free throw success percentage? If Sally makes 50% of her free shot throws, then Sally's probability of making 5 in a row would be 3%.

Examples

freeThrows("75%", 5) ➞ "24%"

freeThrows("25%", 3) ➞ "2%"

freeThrows("90%", 30) ➞ "4%"

Notes

  • The success rate is a string.
  • The function should return a string with the percent sign.
  • Round your answer to the nearest whole number.
javascript
Loading editor…
⌘ ↡ to run
Walks through the solution with reasoning and edge cases.
Next: Robot Path πŸ€– β†’