Hey guys, I’m not quite sure what I’m doing wrong here with this third exercise. I keep getting SyntaxError: Unexpected token ‘else’ but I just can’t see what’s wrong with it, so another pair of eyes would be super helpful!
Here’s my code:
let response;
let score = 75;
let machineActive = true;
if(machineActive) {
// Add your code here
switch (true) {
case (score < 0 || score > 100):
response = 'This is not possible, an error has occurred';
break;
case (score < 20):
response = 'That was a terrible score. Total fail!';
break;
case (score < 40):
response = 'Pretty bad needs improvement';
break;
case (score < 70):
response = 'Passable';
break;
case (score < 90):
response = 'Great';
break;
case (score <= 100):
response = 'Best';
break;
} else {
response = 'The machine is turned off. Turn it on to process your score.';
};
// Don't edit the code below here!
section.innerHTML = ' ';
let para1 = document.createElement('p');
let para2 = document.createElement('p');
para1.textContent = `Your score is ${ score }.`;
para2.textContent = response;
section.appendChild(para1);
section.appendChild(para2);
Thanks in advance for any help!