Last active
March 23, 2023 22:25
-
-
Save sandrabosk/f64b77f0322b940d5cfc41addeeed47e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Suspects Collection | |
const suspectsArray = []; | |
let mrGreen = { | |
firstName: 'Jacob', | |
lastName: 'Green', | |
occupation: 'Entrepreneur', | |
age: 45, | |
description: ' He has a lot of connections', | |
image: | |
'https://pbs.twimg.com/profile_images/506787499331428352/65jTv2uC.jpeg', | |
color: 'green' | |
}; | |
let drOrchid = { | |
firstName: 'Doctor', | |
lastName: 'Orchid', | |
occupation: 'Scientist', | |
age: 26, | |
description: 'PhD in plant toxicology. Adopted daughter of Mr. Boddy', | |
image: 'http://www.radiotimes.com/uploads/images/Original/111967.jpg', | |
color: 'white' | |
}; | |
let profPlum = { | |
firstName: 'Victor', | |
lastName: 'Plum', | |
occupation: 'Designer', | |
age: 22, | |
description: 'Billionaire video game designer', | |
image: | |
'https://66.media.tumblr.com/ee7155882178f73b3781603f0908617c/tumblr_phhxc7EhPJ1w5fh03_540.jpg', | |
color: 'purple' | |
}; | |
suspectsArray.push(drOrchid); | |
suspectsArray.push(profPlum); | |
suspectsArray.push(mrGreen); | |
// or: suspectsArray.push(drOrchid, profPlum, mrGreen); | |
let room1 = { name: 'Dining Room' }; | |
let room2 = { name: 'Conservatory' }; | |
let room3 = { name: 'Kitchen' }; | |
let room4 = { name: 'Study' }; | |
let room5 = { name: 'Library' }; | |
let room6 = { name: 'Billiard Room' }; | |
let room7 = { name: 'Lounge' }; | |
let room8 = { name: 'Ballroom' }; | |
let room9 = { name: 'Hall' }; | |
let room10 = { name: 'Spa' }; | |
let room11 = { name: 'Living Room' }; | |
let room12 = { name: 'Observatory' }; | |
let room13 = { name: 'Theater' }; | |
let room14 = { name: 'Guest House' }; | |
let room15 = { name: 'Patio' }; | |
// Rooms Collection | |
const roomsArray = [ | |
room1, | |
room2, | |
room3, | |
room4, | |
room5, | |
room6, | |
room7, | |
room8, | |
room9, | |
room10, | |
room11, | |
room12, | |
room13, | |
room14, | |
room15 | |
]; | |
// Weapons Collection | |
const weaponsArray = [ | |
{ name: 'rope', weight: 10 }, | |
{ name: 'knife', weight: 8 }, | |
{ name: 'candlestick', weight: 2 }, | |
{ name: 'dumbbell', weight: 30 }, | |
{ name: 'poison', weight: 2 }, | |
{ name: 'axe', weight: 15 }, | |
{ name: 'bat', weight: 13 }, | |
{ name: 'trophy', weight: 25 }, | |
{ name: 'pistol', weight: 20 } | |
]; | |
function selectRandom(theArray) { | |
let randomIndex = Math.floor(Math.random() * theArray.length); | |
return theArray[randomIndex]; | |
// const item = theArray[randomIndex]; | |
// return item | |
} | |
function pickMystery() { | |
let mystery = {}; | |
let theSuspect = selectRandom(suspectsArray); | |
let theWeapon = selectRandom(weaponsArray); | |
let theRoom = selectRandom(roomsArray); | |
mystery.suspect = theSuspect; | |
mystery.weapon = theWeapon; | |
mystery.room = theRoom; | |
return mystery; | |
// return { | |
// suspect, | |
// weapon, | |
// room | |
// }; | |
} | |
function revealMystery(envelope) { | |
// const { suspect, weapon, room } = 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