Hello. I am trying to figure out how to add a conditional that displays the message for the user to turn the machine on. I have linked below what I have so far: https://codepen.io/thenewcoderfromldn/pen/XWXmMYE
The assignment link is the following: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Test_your_skills:_Conditionals
Any help would be greatly appreciated.
Hi there @djkamar411! Welcome to the community, and thanks for sending your code in.
This is nearly perfect; you just needed to include and else
clause so that a message is shown whether machineActive
is false
or true
.
Something like this would be fine:
if (machineActive) {
if (score < 0 || score > 100) {
response = 'This is not possible, an error has occured.';
} else if (score >= 0 && score <= 19) {
response = 'That was a terrible score - total fail!';
} else if (score >= 20 && score <= 39) {
response = 'You know some things, but it\'s a pretty bad score. Needs improvement.';
} else if (score >=40 && score <= 69) {
response = 'You did a passable job, not bad!';
} else if (score >= 70 && score <= 89) {
response = 'That\'s a great score, you really know your stuff.';
} else {
response = 'What an amazing score! Did you cheat? Are you for real?';
}
} else {
response = 'Turn the machine on to process your score';
}
Thanks so much! Will definitely ask for more help if I get stuck again.