Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Javascript level 4 - lesson 4

Use if, else if and else statement to do so.
Use if statement to check if the value of the signal variable is green, if green, print the following on the console: Go
Then use else if statements, to check if the signal is yellow, or red. In the case of yellow, print Wait on the console, and in the case of red, print Stop on the console.
In the else block, print, Error on the console.
For, green = Go,

yellow = Wait,

red = Stop,

and apart from these values = Error.
by

1 Answer

kshitijrana14
Try this one

let signal = "yellow";
// write logic here
if(signal == "green") {
console.log("Go");
}
else if(signal == "yellow") {
console.log("Wait");
}
else if(signal == "red") {
console.log("Stop");
}
else {
console.log("Error");
}

Login / Signup to Answer the Question.