MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / main

Function main

javascript_games/ninetyninebottles.js:20–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18console.log('(Press Ctrl-C to quit.)');
19
20async function main() {
21 await sleep(2);
22
23 let bottles = 99; // This is the starting number of bottles.
24 while (bottles > 1) {
25 console.log(bottles, 'bottles of milk on the wall,');
26 await sleep(PAUSE); // Pause for PAUSE number of seconds.
27 console.log(bottles, 'bottles of milk,');
28 await sleep(PAUSE);
29 console.log('Take one down, pass it around,');
30 await sleep(PAUSE);
31 bottles = bottles - 1; // Decrease the number of bottles by one.
32 console.log(bottles, 'bottles of milk on the wall!');
33 await sleep(PAUSE);
34 console.log() // Print a newline.
35 }
36
37 // Display the last stanza:
38 console.log('1 bottle of milk on the wall,');
39 await sleep(PAUSE);
40 console.log('1 bottle of milk,');
41 await sleep(PAUSE);
42 console.log('Take it down, pass it around,');
43 await sleep(PAUSE);
44 console.log('No more bottles of milk on the wall!');
45}
46
47main();

Callers 1

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected