I am trying to choose a random word from an array of strings but cannot figure out how.
I have researched on this and here is what I have so far:
roast.js
const roastList = [
'Apples',
'Bananas',
'Pears',
];
const roast = roastList[Math.floor(Math.random() * roastList.length)];
module.exports = {
roast
};
index.js:
case 'roast':
if (!message.mentions.users.size) {
return message.reply('you need to tag a user in order to roast them!');
}
message.channel.send(`Hey ${taggedUser}, ${roast}`);
break;
I copied the code so the fruits are placeholders. I hope that I can get different fruits each time I output roast.
roastexport.