Skip to content

Instantly share code, notes, and snippets.

@bnoden
Created March 22, 2016 01:02
Show Gist options
  • Save bnoden/15577de3cba016220a8e to your computer and use it in GitHub Desktop.
Save bnoden/15577de3cba016220a8e to your computer and use it in GitHub Desktop.
Heterogeneous Arrays
function Monster(id, name, cry, is){
this.id = id
this.name = name
this.cry = cry
this.is = is
}
var putridMoldyMan = new Monster(231, "Putrid Moldyman", '"Bleh"', true)
var myArray = [putridMoldyMan.id, putridMoldyMan.is, putridMoldyMan.cry, putridMoldyMan]
console.log(myArray[3].name + " jumped out of the trashcan!")
var wannaFight = prompt(myArray[3].name +
" jumped out of the trashcan!\nWanna fight " +
myArray[3].name + "?\nY/N").toUpperCase()
if (wannaFight[0] == 'Y')
console.log(myArray[3].name + ':\n' + myArray[3].cry)
else console.log("Your ran back home to your mommy!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment