Continuing the discussion from Magic Eight Ball:
Hello there, I’m stuck! Can someone let me know my mistake??
Thanks,
Gion
[/codebyte]
let userName = ‘’;
username = ‘Jane’;
username ? console.log(‘Hello, Jane!’) : console.log(‘Hello!’);
let userQuestion = ‘Will I win the lottery?’;
console.log(Jane asked: ${userQuestion});
let randomNumber = (Math.floor(Math.random()*8));
console.log (Math.floor(Math.random()*8));
let eightball = ‘’
switch (eightball) {
case 0 : ‘It is certain’; break;
case 1 : ‘It is decidedly so’; break;
case 2 : ‘Reply hazy try again’; break;
case 3 : ‘Cannot predict now’; break;
case 4 : ‘Do not count on it’; break;
case 5 : ‘My sources say no’; break;
case 6 : ‘Outlook not so good’; break;
case 7 : ‘Sings point ot yes’; break;}
console.log(Eightball says: + ${eightball});
In switch expression suppused to be randomNumber, now because you did’t pass it, your case checks eightball as a condition to change it’s value. Then in statement you should assign new value to eightball.
Try this
switch (randomNumber) {
case 0:
eightball = 'It is certain';
break;
...
}
I linked a guide.
Mark the code and press the </>
You won’t be able to format your initial code anymore because there is a limited time frame in which you can edit a post. So just copy and paste it.
Thanks, now I see the parenthesis mistake, but could not run it correctly anyway. Do you have the patient to have another look please? Sometimes I try and try but keep failing…
I’ll try to format, hope it works…
Thank you so much!
let userName = ‘’;
username = ‘Jane’;
username ? console.log(‘Hello, Jane!’) : console.log(‘Hello!’);
let userQuestion = ‘Will I win the lottery?’;
console.log(Jane asked: ${userQuestion});
let randomNumber = (Math.floor(Math.random()*8);
console.log (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 = ‘Sings point ot yes’; break;}
console.log(`randomNumber says: + ${eightball}`);
`
If you copied the unformatted code, the speech marks won’t be converted to valid ones once you pasted the code and formatted it. So you will have to correct that maually. If that is the code you run, that will be a reason why it throws a syntax error.
Other than that there is an issue now with these lines:
You do not have a matching amount of opening and closing parenthesis in these lines.