The tester is reporting false
as my output on test1.
I have used console.log in the educative framework and locally debugged my script. the output is true for test1, which is the expected output.
log output prints vertices count, then iteration number, contents of a Set, and, just before returning, the value of hasCycle.
4 '-------------'
0
Set { 2 }
1
Set { 2, 0 }
2
Set { 2, 0 }
already visited 2 true
3
Set { 2, 0 }
true
note the late line - hasCycle is true