Why isnt this code working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why isnt this code working

Okay im trying to make somthing that you type in your zodiac and it will tell you what animal you are but I ONLY WANT IT TO ALERT YOU OF THE ANIMAL IF IT MATCHES THE ZODIAC. var Taurus = "Fox"; var Aries = "Dog"; var Capricorn ="Bear"; var Libra = "Cat"; var Sagttarius = "Horse"; var Aquarius = "Dolphin"; var Pisces = "Turtle"; var Cancer = "Goat"; var Gemini = "Bird"; var Leo = "Lion"; var Virgo = "Bull"; var Scorpio = "Crab"; prompt ("Enter Zodiac"); if(prompt === Scorpio);{ alert ("Crab"); }

4th Aug 2018, 1:41 AM
SarahDiamondFox
SarahDiamondFox - avatar
2 Answers
0
Error in code is, if(prompt === Scorpio) which is equivalent to, if(prompt === "Crab") Here's how i would do it. https://code.sololearn.com/WpRnAbxTZIbc/#js story values in a dictionary using zodiac as key and animal as value check if prompted animal exists in dictionary, if it does alert
4th Aug 2018, 2:01 AM
JME
0
Oh thank you im not that good with js but im learning so thank you for helping me.
4th Aug 2018, 2:52 AM
SarahDiamondFox
SarahDiamondFox - avatar