-
Notifications
You must be signed in to change notification settings - Fork 0
/
magicEightBall.js
45 lines (43 loc) · 1.37 KB
/
magicEightBall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const userName = '';
userName === 'Jane' ? console.log('Hello, Jane!') : console.log('Hello!');
let userQuestion = 'Is it going to rain tonight?';
console.log(`You asked "${userQuestion}"`);
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;
}*/
if (randomNumber = 0) {eightBall = 'It is certain';}
else if (randomNumber = 2) {eightBall = 'Reply hazy try again';}
else if (randomNumber = 1) {eightBall = 'It is decidedly so';}
else if (randomNumber = 3) {eightBall = 'Cannot predict now';}
else if (randomNumber = 4) {eightBall = 'Do not count on it';}
else if (randomNumber = 5) {eightBall = 'My sources say no';}
else if (randomNumber = 6) {eightBall = 'Outlook not so good';}
else if (randomNumber = 7) {eightBall = 'Signs point to yes';}
else {eightBall = 'Error!';}
eightBall ? console.log(eightBall) : console.log('Error!');