Created
October 23, 2019 13:40
-
-
Save josecarneiro/a6aef752e5d69c26da6db085a6601f89 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
// ITERATION 2 | |
function selectRandom(array) { | |
const randomIndex = Math.floor(Math.random() * array.length); | |
return array[randomIndex]; | |
} | |
function pickMystery() { | |
const suspect = selectRandom(suspectsArray); | |
const weapon = selectRandom(weaponsArray); | |
const room = selectRandom(roomsArray); | |
return { | |
suspect, | |
weapon, | |
room | |
}; | |
} | |
// ITERATION 3 | |
function revealMystery(envelope) { | |
return `${envelope.suspect.firstName} ${envelope.suspect.lastName} killed Mr. Boddy using the ${envelope.weapon.name} in the ${envelope.room.name}!`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment