Hi all,
I have just completed this project and below is what I came up with 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: [
'determined',
'ambitious',
'sufficient',
'strong',
'powerful',
]
}
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 = () => {
console.log('\n\n\n');
const intro = `Hey, \nyou ${generateAdjectiv(messages.adjectivOfTheDay)} person!`
console.log(intro);
let divider = ''
for(let i = 0; i < intro.length; i++) {
divider += '*';
}
console.log(`Here is your message: \n${divider} \n${generateMotivationMessage(messages.motivationOfTheDay)}`);
console.log('\n\n\n');
};
generateMessage();