Skip to content

Tag: loops

Search in array of precise positions

I currently have a painting with 64 tiles, each color is defined. Grey is a valid position, black is an invalid position (a wall), green is player pawn 1 and red is player pawn 2. When player 1 clicks on his green pawn he can choose to duplicate himself on a valid tile close to him (Grey) or jump on

Why does this GET request create infinite loop? (React)

First, please look at the code. The problem happens with this following code. When I add actionItemArray in the second argument array, It keeps looping these two console.log events. When I delete actionItemArray from the second argument of useEffect Hook, I have to refresh my page to added, deleted and edited…

browser freezing when in while loop (snake game)

I’m making the popular snake game for js homework. I have a function which is meant to ensure that after an apple is eaten it moves to a different location on the canvas while not being on any part of the snake, the function without the loop works fine (though apples are placed on the snake too): the fu…

Vuejs Iterate through a ref object

I have a small problem, I get my ref object from that method And i want to use another method using that ref object : But i can’t iterate through : Is there anyway to make that work ? Thank you 🙂 Answer As the response is an object and not an array, you cannot iterate over it with forEach,