Where I'm doing wrong? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
3 Answers
+ 6
Hello, Abhishek Singh ! Your mistake was that you specified your value without quotes, without quotes, javascript, recognizes as another variable and looks for it var color = "yellow"; if (color == "blue") { document.write("This is blue."); } else if (color == "red") { document.write("This is red."); } else if (color == "green") { document.write("This is green."); } else if (color == "orange") { document.write("This is orange."); } else { document.write("Color not found."); }
22nd Jun 2018, 11:57 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 1
Alexander Sokolov ohh Thank you bro🙏
22nd Jun 2018, 12:00 PM
Abhishek Singh
Abhishek Singh - avatar
0
You should put "yellow" into brackets. Without brackets, interpretator thinks, that yellow is another variable and, because it is not defined, sets color to undefined too.
22nd Jun 2018, 11:58 AM
Дмитро Іванов
Дмитро Іванов - avatar