+ 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"); } };
5 Answers
+ 4
Your output should be matched with expected output
else
{
console.log("Draw");
}
+ 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.
0
You have not call the main function which will show console.
main();
- 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 ^^
- 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