+ 2

What is wrong with my code?(Javascript)can't complete lesson:("organized Bot Task" else-if Statements)

let color = ("green"); /* red => 1 green => 2 black => 3 other cases => unknown */ if (color=="red"){ console.log(1); } else if (color=="green"){ console.log(2); } else if (color =="black"){ console.log(3); } else { console.log("unknown"); }

2nd Sep 2023, 5:30 PM
SKB
SKB - avatar
2 odpowiedzi
+ 3
SKB , You hard-coded the input... instead taking input from the user... Use prompt statement to receive input from user... let color =prompt("Enter color:");
2nd Sep 2023, 6:33 PM
Riya
Riya - avatar
+ 2
Thank you-That helped:)
2nd Sep 2023, 6:51 PM
SKB
SKB - avatar