"In your insertion, you should grow the tower if a coin returns 'heads'. Assume that you have a completely fair coin that always alternates between heads and tails (but you don't know the value that it last returned)." code example
Example: how to Write a program that simulates a coin toss using random method of Javascript Math class
var head = 1;
var tail = 2;
var toss = Math.random() * 2;
var floor = Math.floor(toss)
if(floor === 0){
document.write("0 <br> Random Coin Value: Head")
} else if(floor === 1)
{
document.write("1 <br> Random Coin Value: Tails")
}