working on this object and need help | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 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!"); }

22nd Dec 2022, 1:36 AM
Keyon Eubanks
Keyon Eubanks - avatar
2 Réponses
+ 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) {};
22nd Dec 2022, 9:27 AM
Saif
Saif - avatar
+ 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 ...
22nd Dec 2022, 11:10 AM
Ipang