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

Can someone please help me correct my code here?

I’m getting an error Unexpexted token ‘else’ The code is mentioned below

Code

const calcAvgScore = (score1, score2, score3)=>{
return (score1 + score2 + score3)/3;
}

function checkWinner(avgKoalas, avgDolphins){
 if(avgKoalas > (avgDolphins*2))
 {
     console.log(`Koalas win ${avgKoalas} vs ${avgDolphins}`);
 }
 elseif(avgDolphins > (avgKoalas*2))
 {
     console.log(`Dolphins win ${avgDolphins} vs ${avgKoalas}`);
 }
 else
 {
     console.log(`no winner ${avgDolphins}, ${avgKoalas}`);
 }
}

const koalasAvg = calcAvgScore(65, 54, 49);
const dolphinsAvg = calcAvgScore(44, 23, 71);

checkWinner(koalasAvg, dolphinsAvg);

this is the error I’m getting.
Uncaught SyntaxError: Unexpected token ‘else’ (at index.js:16:3)
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

>Solution :

add space in between elseif like this else if

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