Assessment needed.! Conditionals 1

Hi guys! I’m a total newbie to wd. Need your assessments or thoughts. Thanks!

/* Conditionals 1 */

let season = ‘summer’;
let response;

if (season === ‘summer’) {
response = “It is summer now.”
} else if (season === ‘winter’) {
response = “It’s winter”;
} else {
response = ‘We don’t know what season it is right now’;
}

/* Conditionals 2 */

let response;
let score = 18;
let machineActive = false;

if (machineActive) {
if (score < 0 || score > 100) {
response = “This is not possible, an error has occurred.”;
} else if (score >= 0 && score < 20) {
response = “That was a terrible score — total fail!”;
} else if (score >= 20 && score < 40) {
response = “You know some things, but it’s a pretty bad score. Needs improvement.”;
} else if (score >= 40 && score < 70) {
response = “You did a passable job, not bad!”;
} else if (score >= 70 && score < 90) {
response = “That’s a great score, you really know your stuff.”;
} else if (score >= 90 && score < 100) {
response = “What an amazing score! Did you cheat? Are you for real?”;
}
} else {
response = “The machine is turned off. Turn the machine on to show your score!”;

/* Conditionals 3 */

let machineActive = true;
let pwd = ‘cheese’;

let machineResult;
let pwdResult;

if (machineActive) {
machineResult = “The machine is on. Logging in”;
pwdResult = pwd === ‘cheese’ ? ‘Login success’ : ‘Your password is incorrect. Try again’;
} else {
machineResult = ‘The machine is not active. Please activate the machine and try again’;
}

Below are my viewpoints:

/* Conditionals 1 */

The conditionals looks okay. The assignment of values to the variable looks good.

/* Conditionals 2 /
/
Conditionals 3 */

Both conditionals look good, and should work as coded.

However, I think curly quotes ( and ) should be replaced with straight quotes ( " ). This is to prevent issues when using different coding environments.

1 Like

Thank you!
Can you please point where exactly those curly quotes were used in my codes above? Couldn’t find one. Thanks again!

Alright.

I can see that most of the quotes are like this ( and ) instead of straight quotes ( '' and ' ).

Note, the code works. I am just saying some environment are restrictive.

1 Like

Got it! Thanks for the feedback!!

1 Like