A JavaScript game of slots.

2017-05-06 05_27_37-Slots.png

Speaking of one-click JavaScript games, here’s my take on the classic slots game. It basically generates three small numbers at random, and if they all match, you win. Simple.

<!DOCTYPE html>
<table border="1">
<td><p id="a">?</p></td>
<td><p id="b">?</p></td>
<td><p id="c">?</p></td>
<td><p id="d">SPIN THE SLOTS</p></td>

<button onclick="myFunction()">Spin</button>

function myFunction()
var aa=Math.floor((Math.random()*2)+1);
var bb=Math.floor((Math.random()*2)+1);
var cc=Math.floor((Math.random()*2)+1);

if (aa==bb && bb==cc)



In a future version I will make gold coins fall from your screen.

Leave a Comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s