My code isn't working - Please Help!

Hey all… I was just messing around with JavaScript, and I was making a sort of dragon encyclopaedia for my little brothers who are How To Train Your Dragon addicts, but the code is not working. When you run the script and enter the name of a dragon, for example, the Terrible Terror, it comes up with the completely wrong class and special abilities for that dragon, even though it looks like it should work. I am very frustrated and help would be very very much appreciated! Thanks!
Here is my code:
console.log(“Welcome To Dragonpedia!”);
var whatDrag = prompt(“Please enter the full name of the Dragon you would like to learn about in the text box below:”);

var whatClassDrag;
var whatSkills;
var whatInfo;

if(whatDrag == “Monstrous Nightmare” || “Terrible Terror” || “Typhoomerang” || “Fireworm” || “Red Death” || “Hobblegrunt” || “Moldruffle” || “Night Terror”) {
whatClassDrag = “Stoker Class”;
}
if(whatDrag == “Gronkle” || “Whispering Death” || “Screaming Death” || “Hotburple” || “Snafflefang” || “Thunderpede” || “Grapple Grounder” || “Groncicle” || “Catastrophic Quaken” || “Foreverwing” || “Shovelhelm”) {
whatClassDrag = “Boulder Class”;
}
if(whatDrag == “Deadly Nadder” || “Rumblehorn” || “Thunderclaw” || “Mudraker” || “Snifflehunch”) {
whatClassDrag = “Tracker Class”;
}
if(whatDrag == “Timberjack” || “Speed Stinger” || “Stormcutter” || “Raincutter” || “Scuttleclaw” || “Hackatoo” || “Shivertooth” || “Windstriker” || “Razorwhip” || “Thornridge” || “Prickleboggle” || “Devilish Dervish” || “Egg Biter”) {
whatClassDrag = “Sharp Class”;
}
if(whatDrag == “Scauldron” || “Thunderdrum” || “Sea Shocker” || “Bewilderbeast” || “Sliquifier” || “Submaripper” ||
“Shockjaw” || “Sand Wraith” || “Tile Glider”) {
whatClassDrag = “Tidal Class”;
}
if(whatDrag == “Hideous Zippleback” || “Changewing” || “Snaptrapper” || “Boneknapper” || “Smothering Smokebreath” || “Flightmare” || “Sweet Death” || “Death Song” || “Armorwing”) {
whatClassDrag = “Mystery Class”;
}
if(whatDrag == “Night Fury” || “Skrill” || “Snow Wraith” || “Woolly Howl”) {
whatClassDrag = “Strike Class”;
}
else {
whatClassDrag = " - ";
}

if(whatDrag == “Monstrous Nightmare”) {
whatSkills = “The ability to engulf itself in flames when in combat (and in other situations too!)”;
}
if(whatDrag == “Terrible Terror” || “Hobblegrunt” || “Moldruffle” || “Gronckle” || “Hotburple” || “Snafflefang” || “Thunderpede” || “Grapple Grounder” || “Foreverwing” ) {
whatSkills = “No specific special abilities”;
}
if(whatDrag == “Deadly Nadder” || “Rumblehorn” || “Thunderclaw” || “Mudraker” || “Snifflehunch”) {
whatSkills = “Besides the generic tracker class ability to hunt down specific people or things, this dragon has no special capabilities”;
}
if(whatDrag == “Timberjack” || “Stormcutter” || “Raincutter” || “Scuttleclaw” || “Hackatoo” || “Shivertooth” || “Windstriker” || “Razorwhip” || “Thornridge” || “Prickleboggle” || “Devilish Dervish” || “Egg Biter”) {
whatSkills = “Besides their generic super sharp sharp class spikes, this species of dragon has no special capabilities”;
}
if(whatDrag == “Typhoomerang”) {
whatSkills = “The Typhoomerang has a rare ability to fly in a circle so fast that it creates a small tornado of fire”;
}
else if(whatDrag == “Sweet Death” || “Snaptrapper”) {
whatSkills = “This beast has the very special ability to make an enticing smell (supposedly like chocolate) that can attract unknowing prey”;
}

if (whatSkills == null) {
whatSkills = “Sorry, we have no data on this dragons special abilities”;
}

if(whatDrag == “Monstrous Nightmare”) {
whatInfo = “The Monstrous Nightmare is one of the most aggressive, powerful, and stubborn breeds of dragon known to the Vikings. It is classified in the Stoker Class. Before the Red Death was discovered, it was considered the most formidable dragon species to all berkians.”;
}
else if(whatDrag == “Terrible Terror”) {
whatInfo = “The Terrible Terror is a Stoker Class dragon. It is the second smallest of the dragons, after the Fireworm, but also one of the most feared. It loosely resembles the Common or Garden Dragon and is roughly the size of a small cat. The Terror can crawl into Viking homes, sheds, outhouses and shacks, attacking when its prey is least expecting it. The only warning a Terror gives is the hissing sound it makes just before breathing fire. It is capable of such pinpoint accuracy with its flames that it can be considered the sniper of the Dragon World.”;
}
else if(whatDrag == “Typhoomerang”) {
whatInfo = “Typhoomerangs have a unique ability during flight: they rotate (by analogy with the typhoon/ boomerang) at high speeds, zooming through the air. Though, as they rotate, they seem to pop off the objects around them, making them extremely dangerous. Ash leaves a distinctive burn on the ground. The ash apparently acts as a fertilizer; flowers will grow in the burn mark afterwards.”;
}
else if(whatDrag == “Fireworm”) {
whatInfo = “The Fireworm (originally named the Flame Eater) is a Stoker Class dragon. It is like the cockroach of the dragon world, that is, if a cockroach could super-heat its skin to burn everything it touched. It also has traits from bees in that they create gel that’s stored in honeycomb-like structures and have a queen.”;
}
else if(whatDrag == “Red Death”) {
whatInfo = “True to the reputation as the ‘queen of the dragons’, the only grown specimen seen in the franchise demonstrated savage, menacing, and controlling nature that even a deadly Night Fury was frightened of (not unclear whether the other individuals in the species share this personality). In addition, according to Valka, every nests have their queens or kings, indicating that there could be numerous Red Deaths in the world.”;
}
else if(whatDrag == “Hobblegrunt”) {
whatInfo = “More sensitive than most other Stoker Class Dragons, the Hobblegrunt changes color depending on its mood: Yellow means happy, purple means curious, and red means that it is very, very angry (you won’t like me when I’m angry!).”;
}
else if(whatDrag == “Moldruffle”) {
whatInfo = "The Moldruffle is incredibly catlike in nature. They are intelligent and curious but It’s keen senses are quickly distracted. It switches it’s focus from one thing on to another, much similar to a cat. ";
}
else if(whatDrag == “Night Terror”) {
whatInfo = “The Night Terror is a small Stoker Class dragon that flies in overwhelmingly large packs. It is believed to be a relative of the Terrible Terror and the Smothering Smokebreath, except that the Night Terror is strictly nocturnal. The impressive defensive tactic of the Night Terror is to combine into a huge pack, resembling an extremely large dragon.”;
}
else if(whatDrag == “Gronkle”) {
whatInfo = “The Gronkle is one of the toughest (and slowest) dragons in the dragon world, and more than lives up to its looks in the battlefield. It’s heptane/oxygen/rock lava blast will be sure to leave a mark on even the deadliest of dragons.”;
}
else if(whatDrag == “Whispering Death”) {
whatInfo = “The Whispering Death is one of the most feared dragons of the dragon world showing an agressive attitude throughout their lives. As hatchlings and adults, they shown to be able to tunnel underground. Whispering Death has the ability to use its jaw to travel quickly through solid rock, giving it, arguably, the greatest jaw strength in the dragon world; But, despite their powerful jaws, they can’t break through metal.”;
}
else if(whatDrag == “Screaming Death”) {
whatInfo = "The Screaming Death, subspecies of the Whispering Death, is a Boulder Class dragon. According to Fishlegs, it is not documented in the Book of Dragons, but it was named by Tuffnut. Bork the Bold said in his notes that the Screaming Death only hatches once every 100 years. This is odd since if Bork had heard or seen a Screaming Death, it would have been documented in the Book of Dragons. This means he simply didn’t have enough experience with the Screaming Death to name the Screaming Death and only gave a description for them to work with. The Screaming Death is the fourth largest and longest known dragon, after the Red Death, Foreverwing and Bewilderbeast. The adolescent individual that crossed paths with the Dragon Riders of Berk is regarded as one of the strongest dragons they have faced since the Red Death. ";
}
console.log("The " + whatDrag + “.”);
console.log("Class: " + whatClassDrag + “.”);
console.log("Special Abilities: " + whatSkills + “.”);
console.log(whatInfo);

1 Like

That compares whatDrag to "Monstrous Nightmare", but not to "Terrible Terror" - there’s no comparison made on the right side of ||

And since the right side is where a boolean value is expected, it’s treated as such (Boolean(“non-empty string”) → true)

Is there a way I can not short-circuit it like that? (Sorry, I’m quite new to JavaScript)

That wouldn’t help you, short-circuiting stops comparing when the answer can be determined without evaluating everything.

For example true || <anything at all>
There’s no point in continuing, because true || is sufficient to tell that it’ll evaluate to true no matter what follows.

You need to compare each string to your variable. You might find a loop to be helpful.