Mixed messages project: Mixed bot greeting!

Just completed a first pass at the mixed messages project and decided to ask for feedback :slight_smile:

const welcomeNote = {
    greeting: ['Hi! ', 'Hello!', 'Welcome!', 'WatsUp!', 'Howdy!', 'Hey!', 'Good morning.', 'G’day!','Hey there.'],
    introductionForm: ["I'm", 'My name is', "You probably want to know my name? it's", "Haven't seen you here before! I'm", "I don't think we've met before, I'm", "I was looking forward to meeting you. I'm", "Thank you so much for taking the time to meet with me today, my name is"],
    name: ['Anna', 'Viola', 'LostSoul', 'Emma', 'Cortana', 'Samuela', 'Kubernetica', 'Samuel', 'Json', 'Onyxia', 'Nanamo', "Y'shtola", 'Gaius'],
    surname: ['van Belsaur', 'nan Garlond', 'of DOOM', 'ulNamo', 'Leveilleur', 'Heyden', 'Roberts', 'Hext', 'Prestor']

const createMsg = obj => {
    let greeting = welcomeNote.greeting[Math.floor(Math.random() * welcomeNote.greeting.length)];
    let form = welcomeNote.introductionForm[Math.floor(Math.random() * welcomeNote.introductionForm.length)];
    let name = welcomeNote.name[Math.floor(Math.random() * welcomeNote.name.length)];
    let surname = welcomeNote.surname[Math.floor(Math.random() * welcomeNote.surname.length)];

    return `${greeting} ${form} ${name} ${surname}. Did you like my message? I hope we'll get along!`

1 Like

Very cool. I like this implementation. Question for you though, if you instead made a factory method that spit out WelcomeNote objects, and then wanted to pass those objects into your createMsg function, do you think it would work? I’m still new to this, so I’m not 100% sure. But looking at your code, I would have expected expressions within createMsg to reference the ‘obj’ parameter instead of the welcomeNote object.

Food for thought at least.