Fortune Cookie

Fortune Cookie

Thanks for taking a look at my mixed messages project, I decided to create a fortune cookie message generator. Try it out and see what the future holds in store for you!

I really enjoyed this project. The Javascript element was quite simple compared to some of the earlier exercises in the Full Stack course but I appreciated the chance to practice using Git and Github. Also, the chance to come up with our own take on the mixed messages theme was fun. I also took the opportunity to practice some markdown on the README file.

This project took me about 2 1/2 hours. You can find the code in this link to my repo on Github:

Any feedback would be most welcome.

Happy Coding!

Hello, @timothyf

Nice job on your project. One thing to consider. I received the following outputs having run your code several times:

All your dreams is a long way off undefined
undefined ‘might defeat you’ ‘but patience will be needed’
Inner peace is uncertain undefined
undefined undefined ‘but patience will be needed’

The following output is also possible with your current code:

undefined undefined undefined

Can you see why?

Hi, @midlinder

Thanks for the feedback - I hadn’t noticed that at all. I should have tested more!

I checked the random numbers which were being created and they were producing numbers from 0 - 10:

const randomNum1 = Math.floor(Math.random() * 11);

The problem is that the arrays only have an index of 0 - 9. So when 10 was created as a random number and then array[10] was called, it returned undefined.

So, the solution is to change the random number generator to produce numbers from 0 - 9:

const randomNum1 = Math.floor(Math.random() * 10);

I have fixed it now and updated the github repo. I had to wrestle with git and github and managed to remove my readme file but I got there in the end! It’s all been a learning experience so thanks for pointing out the error :slight_smile: Let me know if it’s still not working!

1 Like

Hi Tim,

I have tested your program and particularly liked the first two messages that were randomly generated for me:
“Your dream job can be yours and you have already found it” and “The road to discovery can be yours and you are closer than you think”. Surprisingly appropriate, considering the fact that I’m doing this course as part of an overall IT Career Switch course!

Your coding approach was very similar to mine in terms of having three different arrays and a function that concatenated the randomized array outputs. I am about to post my solution - a random ‘subject - verb - adverb’ sentence generator, and would appreciate any feedback.

Cheers mate,

Chris Larham

Mixed Messages: Random ‘subject - verb - adverb’ Sentence Generator

Hi Chris,

Thanks - I’m glad my words of wisdom have been encouraging! I’m also doing this course through IT Career Switch, I was attracted by the guarantee of a job at the end of it. I hope it all goes well for you and that you’re enjoying it so far.

I like your random sentence generator, especially the way it checks the entries and adjusts them to make it work grammatically. Something similar could be used to check user input and make sure the output made sense. I also liked your README file - the example output is very handy for getting an idea of how the program works.

I’m taking notes!

1 Like