Can anyone spot the problem? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Can anyone spot the problem?

In line 17, it checks if one of the winning scenarios is a subset of the placed marks. It should indicate when someone wins, but it always returns false, even when it SHOULD be true. When I tested it with other arrays, it returned true https://code.sololearn.com/WJAmTod96lFU/?ref=app

8th Jun 2019, 12:19 PM
Airree
Airree - avatar
1 Answer
+ 3
Airree The problem is that you are trying to compare strings with numbers. In this case index is a string. You can use unary operator '+' to convert index from string to number at line 15 Mark[turn].push(+index); https://code.sololearn.com/WZr70zT0zCIs/?ref=app
8th Jun 2019, 2:37 PM
ODLNT
ODLNT - avatar