Hello mates !
-Puzzle : The descent-
I can’t get why my code is not working if anyone can take a look ?
// game loop
while (true) {
var mountains = [];
var max = Math.max(null, mountains);
for (var i = 0; i < 8; i++) {
var mountainH = parseInt(readline());
mountains.push(mountainH);
}
print(mountains.indexOf(max));
}
this code outputs me -1 for the tests 1 and 2, then 0 for tests 3,4,5
according to the indexOf docs, -1 means that the value is not found.
Maybe a scope problem ?
Anyway thanks for your time !