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....

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!