Created
March 24, 2019 03:37
-
-
Save Damimd10/d6357bd327ea8fc4ad8c94c062c957cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const heroes = [ | |
{ | |
name: 'Batman', | |
isFromDC: true, | |
info: function() { | |
console.log(`${this.name} is ${this.isFromDC ? '' : 'not '} from DC.`) | |
}, | |
}, | |
{ | |
name: 'Spiderman', | |
isFromDC: false, | |
info: function() { | |
console.log(`${this.name} is ${this.isFromDC ? '' : 'not '} from DC.`) | |
}, | |
}, | |
] | |
function pickRandom(arr) { | |
return arr[Math.floor(Math.random() * arr.length)] | |
} | |
pickRandom(heroes).info() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment