let userName = ''; /* Con nombre o sin nombre */ userName ? console.log(`Hello, ${userName}!`) : console.log('Hello!'); /* Se guarda la pregunta */ let userQuestion = 'Is this true?'; /* Se muestra la pregunta */ console.log(`Hey ${userName}! You just asked this: ${userQuestion}`); /* Se genera un número aleatorio entre 0-8 */ randomNumber = Math.floor(Math.random() * 8); /* Se guarda la respuesta en una variable */ let eightBall = ''; /* Se guardan distintas respuestas para el número que toque */ // takes in randomNumber, then eightBall = 'Reply' // you can use if/else or switch; // If the randomNumber is 0, then save an answer to the eightBall variable; if randomNumber is 1, then save the next answer, and so on. /* Se utiliza switch */ /* switch (randomNumber) { case 0: eightBall = 'It is certain'; break; case 1: eightBall = 'It is decidedly so'; break; case 3: eightBall = 'Reply hazy try again'; break; case 4: eightBall = 'Cannot predict now'; break; case 5: eightBall = 'My sources say no'; break; case 6: eightBall = 'Outlook not so good'; break; case 7: eightBall = 'Signs point to yes'; break; } */ /* Se utiliza if */ if (randomNumber === 0) { eightBall = 'It is certain'; } if (randomNumber === 1) { eightBall = 'It is decidedly so'; } if (randomNumber === 2) { eightBall = 'Reply hazy try again'; } if (randomNumber === 3) { eightBall = 'Cannot predict now'; } if (randomNumber === 4) { eightBall = 'Do not count on it'; } if (randomNumber === 5) { eightBall = 'My sources say no'; } if (randomNumber === 6) { eightBall = 'Outlook not so good'; } if (randomNumber === 7) { eightBall = 'Signs point to yes'; } /* Se muestra */ console.log(eightBall);