Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

JS -> Uncaught ReferenceError: Dolphins is not defined

So I’m trying to get better at JS as I am very weak in the language so took a course and I’m on one of the challenges.
I’m sure there is probably an easier way to get my answers on this task but that’s not what I’m looking for here, I’m getting the error described in the title but not sure why… when I run the script on index.html file I get the error:

Uncaught ReferenceError: Dolphins is not defined

Any help I would really appreciate it on what is causing this error 🙂

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

const teamA = Dolphins;
const teamB = Koalas;

const avgScoreDolphins = 96 + 108 + 89 / 3;
console.log(avgScoreDolphins)

const avgScoreKoalas = 88 + 91 + 110 / 3;
console.log(avgScoreKoalas)

if (avgScoreDolphins >= avgScoreKoalas) {
    console.log(`The winning team is ${teamA}`)
} else if (avgScoreKoalas >= avgScoreDolphins) {
    console.log(`The winning team is ${teamB}`)
}
else (avgScoreDolphins === avgScoreKoalas); {
    console.log(`The competition has ended in a draw with ${teamA} and ${teamB}`)
}
const teamA = Dolphins;
const teamB = Koalas;

const avgScoreDolphins = 96 + 108 + 89 / 3;
console.log(avgScoreDolphins)

const avgScoreKoalas = 88 + 91 + 110 / 3;
console.log(avgScoreKoalas)

if (avgScoreDolphins >= avgScoreKoalas) {
    console.log(`The winning team is ${teamA}`)
} else if (avgScoreKoalas >= avgScoreDolphins) {
    console.log(`The winning team is ${teamB}`)
}
else (avgScoreDolphins === avgScoreKoalas); {
    console.log(`The competition has ended in a draw with ${teamA} and ${teamB}`)
}

>Solution :

Your problem is, that you haven’t defined the variable Dolphines yet. So JavaScript thinks, that Dolphines is a variable. But it isn’t one because it isn’t defined anywhere.

Since you probably want to assign a value to the variable teamA, you should wrap Dolphines with double quotes (").
Of course, you should also wrap Koalas in double quotes.

const teamA = "Dolphins";
const teamB = "Koalas";
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading