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.

1 Answer

Try this one

let signal = "yellow";
// write logic here
if(signal == "green") {
else if(signal == "yellow") {
else if(signal == "red") {
else {

Login / Signup to Answer the Question.