Created
March 28, 2019 14:45
-
-
Save franciscoandres/606f9d54e78bfb0dc3c302e343539c44 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 quotes = [ | |
{ | |
"chelsea_fc": [ | |
"If they made a film of my life, I think they should get George Clooney to play me. He's a fantastic actor and my wife thinks he would be ideal.", | |
"It will be the strongest Champions League ever. Every shark will be there." | |
] | |
}, | |
{ | |
"madrid": [ | |
"I know Madrid is a special club. Madrid is politics. Madrid is not about football, Madrid is not about sport, is about many things around.", | |
"We would have only lost if there were six Inter players left on the pitch.", | |
"I had just one problem with Cristiano, very simple, very basic and it's from a tactical aspect that I noticed, which I brought up in order to improve upon and make him better. And at that moment he didn't take it very well because maybe he thinks he knows everything and the coach cannot help him to develop more." | |
] | |
}, | |
]; | |
function getRandom (array) { | |
return array[Math.floor(Math.random() * array.length)]; | |
} | |
function handleArray (array) { | |
const randomKey = getRandom(array); | |
for (const key in randomKey) { | |
if (randomKey.hasOwnProperty(key)) { | |
const element = randomKey[key]; | |
return { | |
team: key, | |
quote: getRandom(element) | |
} | |
} | |
} | |
} | |
console.trace(handleArray(quotes)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment