Mixed Messages Project: Inspirational Messages for Founders

Hi everyone,

For my mixed messages project, I generated a random message geared toward founders to help with motivation and balance. I’m currently learning how to code at night while being a co-founder of a health and wellness startup called Tune (www.tune.studio) so I partly created it for selfish reasons. :wink: The project was relatively easy since I’m familiar with basic programming concepts from Python. I’m still thinking about incorporating HTML/CSS to get more practice.

All feedback is welcome and feel free to use it yourself! I personally run it in the mornings for inspiration! :hugs:

Github Repository: https://github.com/jasbneal/mixed_messages

1 Like

Hi @jasbneal,

Well done. I really liked your README.md file, it’s an example of great documentation (something I’ve got to get better at).

fyi I didn’t clone your repo and run it, just looked at the code and your screenshot. Based on that, it looks good and like it works fine.

Potential refinements to consider:

  • Try using template literals as a more compact way to return the message.
  • Perhaps store inspoQuotes as an array of objects, rather than an array of arrays. Arrays are usually for unrelated data lists, while objects allow relational data to be stored (the person and the quote are directly related to one another). i.e. {name: 'Larry Page, Google co-founder', quote: Always deliver more than expected."} This would then be called with obj['inspoQuotes'][selection1][name] and obj['inspoQuotes'][selection1][quote].
  • If you are going to incorporate HTML/CSS, you might want to restructure the data a little to separate name from job title - so you can style these differently on the page.
  • For future reference, it’s a good idea to link to the lesson in your request for help so we can read the requirements you’re trying to meet.

Thanks for sharing your code, and good luck :slight_smile:

Hi @lucitemple, thank you so much for the feedback, it’s incredibly helpful!

Re: structuring the inspoQuotes as an array of objects, I had that idea but I couldn’t figure out how to randomly select an object since they’re unordered (I believe a randomly generated number that served as the index wouldn’t work). Any idea on how to randomly select an object if I were to make that switch? Perhaps there’s a method out there that exists to do so?

Thanks again for your feedback! :upside_down_face:

1 Like

Think of it like this… at the moment inspoQuotes stores an array of arrays, and to access the nested array (that has the [name, quote]), you write ‘obj[‘inspoQuotes’][index]’.

To randomise which nested array is selected from the top level array, you used a constant set to the value of a random number using the Math methods ‘obj[‘inspoQuotes’][selection1]’ and then use [index] to select the bit of information you want within the nested array.

To store that last bit of data as an object instead of a nested array, we still have the same data structure up until that point. An array of objects, instead of an array of arrays, is still an array. The randomised index method still works on the array part of the data structure.

It is only the data in the object at the end that would need to be accessed by its keys. So instead of accessing by [0] or [1], you access by [name] or [quote].

Perhaps I should also clarify, this could also be accessed with dot notation. obj.inspoQuotes.selection1.name

Using brackets to access the data structure is not limited to arrays, can be used for objects, or can use dot notation.

@lucitemple Ah yes, I understand! I had thought of doing objects nested in an object but I didn’t think of objects nested in an array! I made the modification in my code, you’re welcome to see it here if you like (changed to template literals too): mixed_messages/script.js at main · jasbneal/mixed_messages · GitHub

Thanks again for your feedback, greatly appreciated! :hugs:

1 Like