Question: Introduction to JavaScript Programming with Nothing but a Browser Heads... Heads.... Heads. A weaker man might be moved to re-examine his faith, if in nothing

Introduction to JavaScript Programming with Nothing but a Browser
Heads... Heads.... Heads. A weaker man might be moved to re-examine his faith, if in nothing else at least in the law of probability Tom Stoppard, Rosencrantz and Guildenstern Are Dead, 1967 Write a function consecutiveHeads (numberNeeded) that simulates tossing a coin repeatedly until the specified number of heads appear consecutively. At that point, your program should display a line on the console that indicates how many coin tosses were needed to complete the process. The following console log shows one possible execution of the program: JavaScript Console > consecutiveHeads (3); Tails Heads Heads Tails Heads Heads Heads It took 7 tosses to get 3 consecutive heads
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
