Skip to content

Commit fc433a3

Browse files
committed
[Shreyash]: Added code to get output head or tail randomly
1 parent ae2c0f2 commit fc433a3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
Program to simulate coin flip and print out "Heads" or "Tails" accordingly.
3+
*/
4+
5+
// Generating random number 1 or 2
6+
7+
let coinFlip = Math.random();
8+
9+
if (coinFlip <= 0.5) {
10+
console.log("\n Coin flipped : Heads \n");
11+
}
12+
else {
13+
console.log("\n Coin flipped : Tails \n")
14+
}

0 commit comments

Comments
 (0)