Random Message Generator

Hey all!

I just finished my Mixed Messages project. it took around 30 minutes to do it. It easy I just needed to type a lot due to the Zodiak info volume I used.

Please review my code tell me what would you do better or different a more efficient way. Thanks in advance,

Here is the link to the GitHub repo:

Regards,
Rashad

Hi Rashad,

Cool project :) Instead of randomly generating a sign, maybe it could be linked to a random famous person perhaps? I've simplified your code by using each sign as an object within an array, I haven't done them all, but its just to give you an idea. Gets rid of the need for the switch statement. See what you think below.

James


const aries = {
    name: "Aries",
    period: 'March 21 - April 19',
    sign: '♈︎'
}
const taurus = {
    name: "Taurus",
    period: 'April 20 - May 20',
    sign: '♉︎'
}

const messages = [aries, taurus];

const randomMessage = () => {
const num = Math.floor(Math.random()*messages.length);
console.log(`You were born between {messages[num].period} with sign of {messages[num].name} and symbol ${messages[num].sign}`)
}
randomMessage();

Thank you, brother.

I like your approach better :). The only reason I made it my way is that the requirement was to create arrays inside the object :slight_smile:

1 Like