var cards;
function createCards() {
cards = {
chance: [{
title: 'Advance to go',
type: 'move',
position: 40
}, {
title: "Advance to London",
type: "move",
position: 39
}, {
title: "Your ass is going to jail",
type: "move",
position: 10
}, {
title: "Advance to Rome",
type: "move",
position: 24
}, {
title: "Advance to Charles de Gaulle",
type: "move",
position: 15
}, {
title: "Advance to Amsterdam",
type: "move",
position: 11
}, {
title: "Go back 3 spaces",
type: "movex",
position: -3
}, {
title: "No drink and driving mate1",
type: "bill",
bill: 20
}, {
title: "Get out of Jail free card",
type: "bill",
bill: 150
}, {
title: "Pay school fees",
type: "bill",
bill: 150
}, {
title: "Speeding fine",
type: "bill",
bill: 150
}, {
title: "Bank pays you dividend",
type: "bonus",
bonus: 40
}, {
title: "You have won the competition",
type: "bonus",
bonus: 200
}, {
title: "Your building loan matures",
type: "bonus",
bonus: 200
}, {
title: "You are assessed for street repairs $40 per house $115 per hotel",
type: "billx"
}, {
title: "House repairs $25 per house $100 per hotel",
type: "billx"
}]
};
alert(cards["chance"].length);
}
function pickCard() {
var x = Math.floor(Math.random() * ((cards["chance"].length-1 - 0) + 1) + 0);
var title = cards.chance[x].title;
console.log(x + ". " + title);
alert(cards["chance"].length);
popit(x);
//pop the array we just picked
//adjust Math.floor since there are only 15 cards to pick from instead of 16
}
function popit(x){
var i=0;
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.