Mixed Messages - Motivation of the day!

Hi all,

I have just completed this project and below is what I came up with :slight_smile: any improvement suggestions would be much appreciated :), thank you!

The topic of my project is motivational messages. Basically, by running the script the person would see a greeting message within the same topic and an inspiring message.

const messages = {
  motivationOfTheDay: [
    'Act as if what you do makes a difference. It does.',
    'Success is not final, failure is not fatal: it is the courage to continue that counts.',
    'Never bend your head. Always hold it high. Look the world straight in the eye.',
    'What you get by achieving your goals is not as important as what you become by achieving your goals.',
    'Believe you can and you\'re halfway there.',
    'When you have a dream, you\'ve got to grab it and never let go.',
    'I can\'t change the direction of the wind, but I can adjust my sails to always reach my destination.',
    'No matter what you\'re going through, there\'s a light at the end of the tunnel'
  adjectivOfTheDay: [

const generateAdjectiv = (arr) => {
  const arrLength = arr.length;
  return arr[Math.floor(Math.random() * 1 * arrLength)];

const generateMotivationMessage = (arr) => {
  const arrLength = arr.length;
  return arr[Math.floor(Math.random() * 1 * arrLength)];

const generateMessage = () => {
  const intro = `Hey, \nyou ${generateAdjectiv(messages.adjectivOfTheDay)} person!`
  let divider = ''
  for(let i = 0; i < intro.length; i++) {
    divider += '*';
  console.log(`Here is your message: \n${divider} \n${generateMotivationMessage(messages.motivationOfTheDay)}`);


I really like how yours came out. The word choice on yours when you run it with node, it really makes sense doesnโ€™t feel so random. My bit of feedback is in the arrow functions you have for generating the randomness can actually be just 1 function ran twice 1 for each random word as they are the exact same actions anyway.

example of what I am talking about:

const generateRandomWord = (arr) => {
  const arrLength = arr.length;
  return arr[Math.floor(Math.random() * 1 * arrLength)];
const intro = `Hey, \nyou ${generateRandomWord(messages.adjectivOfTheDay)} person!`
console.log(`Here is your message: \n${divider} \n${generateRandomWord(messages.motivationOfTheDay)}`);

As well
with the function itself. You can remove the 1 in

  return arr[Math.floor(Math.random() * 1 * arrLength)];

so it reads

  return arr[Math.floor(Math.random() * arrLength)];

I believe it is not needed because a number times 1 is itself. so 0.45 * 1 is still 0.45

Hopefully, this all helps.

I am learning all the same and in all honestly, I like the way your project turned out better than mine anyway hah.
Great job!

Design Wolf