Mixed messages: Be Inspired! (Keeping it simple :-) )

This is what I came up with. I’d love your feedbacks.

Hi,

Looks good!

I think the switch conditional may be unnecessary.
Whilst it works, you can use a lot fewer lines to represent it. Dropping the switch will also improve performance (but it probably won’t be noticeable in this example).

You could simply use console.log():

const mixedMessages = () => {
    console.log(inspire[randomNumber]);
}

Hope that Helps!

2 Likes

Hi there!
I too am just completing this project. Very relieved to see yours looks very similar to mine! This looks good. I am a novice working my way through the course and its’ great to see other work. Still trying to work out how to add my work on here and GitHub but getting there. Best wishes with your course!

Drea

1 Like

Hi,

You can add code to the forum by using either of the two options in the editor:
image
Codebytes are useful if you would like others to be able to run the code within the forum.

Both Codecademy and GitHub have great articles on how to upload code to GitHub.

Hope that helps

Hey there!

Thank you so much for this!

x

1 Like

Awesome. Thanks a lot!!

Hi Sam!

Another improvement might be to make the randomNumber dependent on the array length, like this:

const randomNumber = Math.floor(Math.random() * inspire.length)

That way your script is independent of the length of the inspire array. Together with the comment of @bcoding21 this makes the script more versatile :slight_smile:

1 Like

I really love this comment. I learnt how that others reviewing your work is also an opportunity to learn. This was really an eye opener!

My pleasure :slight_smile: Thanks for your reply. I actually uploaded my version of the mixed messages project to GitHub as well. Check it out, it takes quite a different approach but might be interesting as well!

1 Like

hi, this is my end result of the mixed messages project:

https://github.com/AlinBloj/mixed_messages

looking forward for any feedback
thanks

I like your approach