+ 1

Please look at this short piece of code, I can't figure out what I'm doing wrong.

function main() { var goalsTeam1 = parseInt(readLine(), 10); var goalsTeam2 = parseInt(readLine(), 10); // function call finalResult(goalsTeam1, goalsTeam2) } //complete the function function finalResult(goalsTeam1, goalsTeam2) { if (goalsTeam1 > goalsTeam2) { console.log("Team 1 won"); } else if (goalsTeam2 > goalsTeam1) { console.log("Team 2 won"); } else { console.log(" It's a draw"); } };

8th Jul 2021, 9:27 PM
Natanael
5 Respostas
+ 4
Your output should be matched with expected output else { console.log("Draw"); }
9th Jul 2021, 1:09 AM
Simba
Simba - avatar
+ 1
Thanks Simba, the program was expecting the word "Draw" and not "It's a draw", technically there was nothing wrong with the code I wrote. Thanks to all the other people who tried to help but Simba had the only answer.
12th Jul 2021, 9:58 PM
Natanael
0
You have not call the main function which will show console. main();
9th Jul 2021, 2:42 AM
Divya Mohan
Divya Mohan - avatar
- 1
probably at least unexpected space at start of "It's a draw"... be sure to check all your strings to be exactly what tests expect as output ^^
8th Jul 2021, 9:53 PM
visph
visph - avatar
- 1
roughly: utf8: 1 byte (at least) encoding give 8 bits... so values from 0 to 255 can be encoded... basic ascii are encoded as is (1 bit set to 0 and 7 bits = 128 chars), above unicode code points set the 0 bit to 1 and so byte is marked as having more than 1 byte to be decoded ^^ dive on ressources about unicode encoding on internet to learn more ;P
9th Jul 2021, 2:47 AM
visph
visph - avatar