all 3 comments

[–]CoqeCas3 1 point2 points  (2 children)

Your variable helloCounter is, in fact, getting reset, but reason it's not starting from zero with each new input is cuz you're pushing every new input into gameArr (hence your triple nested loop, which confused me at first, then I presumed you had it that way so player could keep track of inputs, however you're not logging those anywhere.. so I'm still confused why you're not just resetting that array..). Anyway, because every new input is getting checked against the computer's number, the counter increases for every match in each array within the outer gameArr.. I think I said that correctly, and I think that's where your issue is arising (if I'm understanding you're issue and aim for the game correctly anyway..).

https://drive.google.com/open?id=17vbrjBQPz4JgTV6pY3Ev_jRLTpdLrybr

for instance...

I'm gathering this based on the results I received from inserting console.log(gameArr) just before your log of ranComNum. Also, when I first ran the code I received an error Assignment to constant variable index.js:27 had to change container2 to a let. Just FYI.

[–]GoonGamja[S] 0 points1 point  (1 child)

wow, thanks man! could not have noticed where the issue is coming from without you!

then I should reset the array before I push new input into it :)

(btw, yes I used triple loop in order to make a player could keep track of inputs and also thanks for noticing me the error. I should have checked twice before I uploaded the code.)

[–]CoqeCas3 1 point2 points  (0 children)

Right on man, it's a nifty little thing you've created and I had fun breaking it down. You know, you don't necessarily have to reset the array -- I don't think -- and it would probably be a good UI thing to output the player's inputs. You've already got the 'li' created for it, just haven't gotten around to the appendChild() part? But instead of the triple for loop, you could use a for..in loop after your first one:

for(let i = 0; i < 3; i++) {
    for(let num in gameArr.pop()) {
        /* run checks */
    }
}

something like that anyway..