Fortune Teller! Check out and let me know

Hello everyone!

Just finished working on my Mixed Messages project. I made a fortune teller that joins random strings from 3 arrays. The message can be either good or bad, so the program first randomly decides this, and then builds the message accordingly.

I am wondering whether I made the right design choices.

Here’s the link to it:

You’re welcome to try it below.
(P.S. fortune prediction only works if you do it once and then you start overthinking about your life)

const goodBeginning = [ 'Good news!', 'Congratulations!', 'Hooray!', 'Look at you!', 'Fantastic!', 'Wink Wink!' ]; const badBeginning = [ 'Bad news.', 'Oh no!', 'dam dam daaaaam', ': (', 'Careful!', 'Be aware!', "I'm sorry..." ]; const goodMiddle = [ 'A long awaited opportunity is coming', 'The desired change will fall from the sky', 'The monetary wish is finally approaching', 'A romantic adventure will entice you', // is this good or bad? ]; const badMiddle = [ 'A betreyal is approaching', 'A harsh fight will come', 'A recession is coming', 'You will be broke', ]; const time = [ 'today', 'tomorrow', 'during this week', 'over the next month', 'during this season', 'this year' ]; // returns a random element of the inputted array regardless of the size of the array const pickRandom = (array) => { const randomIndex = Math.floor(Math.random() * array.length); //console.log('the randomly picked item is: ', array[randomIndex]) return array[randomIndex] } const buildMessage = () => { const message = [] // randomly deciding whether message will be good or bad if (Math.random() < 0.5) { message.push(pickRandom(goodBeginning)) message.push(pickRandom(goodMiddle)) } else { message.push(pickRandom(badBeginning)) message.push(pickRandom(badMiddle)) } message.push(pickRandom(time) + '.'); return message } let myMessage = buildMessage() myMessage = myMessage.join(' ') console.log(myMessage)

Hi, your code looks solid. I love the creativity and this seems like a great idea. As a person reading the code I appreciated the comments as it helped me make sense of what was going on quickly.

Your solution was great. I couldn’t help to notice that this code had the opportunity to be represented in a different way. Below is what I envisioned. Although it seems a bit complex, I think it gives slightly more structure and opens the door to making the resulting sentence very different if you decide to expand in the future.

const badStarts = [...];
const badEnds = [...];
const goodStarts= [...];
const goodEnds = [...];

let sentenceFac = (start, end) => {
	return {
		start: [...],
		end: [..],
		getRandomSentence () {
			return this.startMath.random() * this.start.length] + " " + this.end[Math.random() * this.end.length]

let goodSentence=  sentenceFac(goodStarts, badEnds)//Provide arrays
let badsentence= ...;

function getRandomMessage() {
	if (Math.random() < 0.5){
		return badSentence.getRandomSentence();
	return goodSentence.getRandomSentence();


A few details like the time and middle of the sentence were omitted, but the idea that I’m trying to illustrate remains the same.

Please remember that your code was an elegant solution. Excellent work!!! =)