userName='Greg'; userName ? console.log(`Hello, ${userName}`) : console.log('Hello'); let userQuestion = "Will the Giants win 14 games?"; console.log(`${userName} has asked - ${userQuestion}`); let randomNumber = Math.floor(Math.random()*8); console.log(randomNumber); let eightball = ''; switch(randomNumber){ case 0: eightball = 'It is certain'; break; case 1: eightball = 'It is decidely 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 = 'you can bet on it'; break; case 7: eightball = 'there is no doubt'; break; } console.log(`The Magic 8 ball says ${eightball}.`);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter