New course! Every coder should learn Generative AI!
Try a free lesson+ 1
working on this object and need help
Im working on this object and added an if statement but cant figure out why its not working can some tell me what im doing wrong prompt("Whats your age!") var person = { name: "keyon", age: 25, favColor: "green", height: 175 }; var x = person.name; var y = person.age; var z = person.favColor; var a =person.height; if( y != true){ alert("Intruder Alert!"); } else{ alert("Welcome back!"); }
2 Answers
+ 2
There are many way to get the result you want. The easy one is to put prompot in variable for example s = prompt(“What your age”). and change (y!=true) to ( y!= s) {};
+ 1
Depends on how <person> is qualified as "Intruder". I see you use <person> age to conclude that, but here <person> age is a number, and comparison of a number with a boolean constant (true) didn't make sense.
Describe the condition for deciding whether <person> is to be greeted or warned ...