The code:
const goodfortunes = [
' You will be rich',
' You will live a long life',
' Wednesday looking lucky',
' You have good luck today'
]
let randnum = () => Math.floor(Math.random() * 8);
let randphrase = () => {
if (randnum() === 0) {
console.log(goodfortunes[0])
}else if (randnum() === 1) {
console.log(goodfortunes[1])
} else if (randnum() === 2) {
console.log(goodfortunes[2])
} else if (randnum() === 3) {
console.log(goodfortunes[3])
}
}
console.log(randphrase())
can't get console.log to print goodfortunes index value unless manually logging randphrase(). When manually logging randphrase() it prints an undefined value along with one of the wanted indexes. Anyone know why?