HELP! I don't know what I'm doing wrong: Mixed messages project

Hey Guys, I’m working on the Mixed Messages Project(I made it a fun drinking game). I get no errors but when I run the code, It logs nothing. I double-checked syntax and but I don’t know what I’m doing wrong. Can someone help me?

const drinkOrDare = () => {
    let messagePieceCollector = [''];
    const first = ['Becky ', 'James ', 'Benjamin ', 'Alexa ', 'Timothy ', 'Richard '];
    const second = ['Take one shot ', "Don't take a shot ", 'Take two shots ', 'Take  4 shots '];
    const last = ['or do a handstand', 'or lick the floor', 'or kiss the person to your right on the cheek for 10 seconds', 'or let the person next to you look through your phone for 10 seconds',
        'or win a match of arm-wrestling with the person on your left', 'or put 2 dollars in the prize pot', 'or let the person on your right smack you on your butt cheek as hard they can', 'or claim all the prize pot money', 'or play the rest of the game on all fours, only allowed to bark, not to talk', 'or do 30 push ups', 'or tell everyone an embarrassing secret of yours']

    const firstRandomizer = () => {
        return Math.floor(Math.random() * 6);
    }
    const secondRandomizer = () => {
        return Math.floor(Math.random() * 4);
    }
    const lastRandomizer = () => {
        return Math.floor(Math.random() * 11);
    }
    
  
    const firstindexPicker = () => {
        switch (first[firstRandomizer()]) {
            case 'Becky ':
                messagePieceCollector.push(first[0]);
                break;
            case 'James ':
                messagePieceCollector.push(first[1]);
                break;
            case 'Benjamin ':
                messagePieceCollector.push(first[2]);
                break;
            case 'Alexa ':
                messagePieceCollector.push(first[3]);
                break;
            case 'Timothy ':
                messagePieceCollector.push(first[4]);
                break;
            case 'Richard ':
                messagePieceCollector.push(first[5]);
            Default: console.log('Error at first piece of sentence!')

        }
        switch (second[secondRandomizer()]) {
            case 'Take one shot ':
                messagePieceCollector.push(second[0]);
                break;
            case "Don't take a shot ":
                messagePieceCollector.push(second[1]);
                break;
            case 'Take two shots ':
                messagePieceCollector.push(second[2]);
                break;
            case 'Take  4 shots ':
                messagePieceCollector.push(second[3]);
            Default: console.log('Error at second piece of sentence!')

        }
        switch (last[lastRandomizer()]) {
            case 'or do a handstand':
                messagePieceCollector.push(last[0]);
                break;
            case 'or lick the floor':
                messagePieceCollector.push(last[1]);
                break;
            case 'or kiss the person to your right on the cheek for 10 seconds':
                messagePieceCollector.push(last[2]);
                break;
            case 'or let the person next to you look through your phone for 10 seconds':
                messagePieceCollector.push(last[3]);
                break;
            case 'or win a match of arm-wrestling with the person on your left':
                messagePieceCollector.push(last[4]);
                break;
            case 'or put 2 dollars in the prize pot':
                messagePieceCollector.push(last[5]);
                break;
            case 'or let the person on your right smack you on your butt cheek as hard they can':
                messagePieceCollector.push(last[6]);
                break;
            case 'or claim all the prize pot money':
                messagePieceCollector.push(last[7]);
                break;
            case 'or play the rest of the game on all fours, only allowed to bark, not to talk':
                messagePieceCollector.push(last[8]);
                break;
            case 'or do 30 push ups':
                messagePieceCollector.push(last[9]);
                break;
            case 'or tell everyone an embarrassing secret of yours':
                messagePieceCollector.push(last[10]);
            Default: console.log('Error at last piece of sentence!')

        }
    }


 console.log(messagePieceCollector);

    const joinedMessage = messagePieceCollector.join('')
    
    console.log(joinedMessage);
}

drinkOrDare();

Hi,
is this all of your code? From what I see here your function with all the switch statements (firstindexPicker) never gets called…

Ah! That was the issue. I don’t know how didn’t think of that. Thanks!

1 Like