Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let userName = "";
- // If user gives his name, then userName variable
- // will be set equal to this name
- // I will create another variable in the case the
- // user wants to change this name
- let nameWritten = "Thomas";
- userName = nameWritten || "";
- // If the variable "nameWritten" is not empty, then userName will be set equal to the given nameWritten variable, otherwise it will be the string ""
- console.log(`Hello ${userName}!`);
- console.log();
- let userQuestion = "What's the time?";
- console.log(`${userName} asks this question: ${userQuestion}`);
- // Generating a random number between 0 and 7
- let randomNumber = Math.floor(Math.random() * 8);
- let eightBall = "";
- switch(randomNumber){
- case 0:
- eightBall = "It is certain!";
- break;
- case 1:
- eightBall = "It is decidedly so!";
- break;
- case 2:
- eightBall = "Reply hazy try again!";
- break;
- case 3:
- eightBall = "Cannot predict now...";
- break;
- case 4:
- eightBall = "Do not count on it...";
- 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;
- default:
- eightBall = "It is impossible to go in case 'default'.";
- break;
- }
- // EightBall answers
- console.log(`Eightball answers this: ${eightBall} (${randomNumber})`);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement