Hi all, i am writing a function, below, that is part of a program that finds all possible solutions to a game. There is an array "moves" that contains strings (i.e. "1, 2,4","3,6,9"..etc) all being possible that can be made in the game. the Move function simply runs these values and returns a string of a plausible move while also decrementing "pegsLeft" so the function will eventually end when pegs becomes greater than pegsToRemain -- the number of pegs allowed to remain obviously--
This all works well until the for-loop becomes false. 'i' does not seem to reinitialize itself to 0 when the function gets recalled. This causes an overflowerror the second time the function is called because i is set to moves.length when it starts.
ive tried a few different things such as referring to another variable and other for loops, while loops, if statements and none of them seem to work. its probbaly something silly but i've been staring for too long. any help would be appreciated. thanks