How to move checker pieces to other empty adjacent cells with JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to move checker pieces to other empty adjacent cells with JavaScript?

I have managed to built a checker board with the logic in this code and also the logic to highlight a piece selected by a user. Now I am trying to move a selected piece to a target box with the code in this link https://www.sololearn.com/en/compiler-playground/Wqj1xZCyq6s5 How do I complete the code to move the pieces around, Thank You

5th May 2024, 5:51 PM
Timothy Njiru
Timothy Njiru - avatar
1 Answer
+ 2
I guess you'd have to check if the player's move is valid, then delete the piece from the old position and update it to the new position. If it captures another player's piece, you'll have to remove that one. I'm not sure if the sign up and possibly gambling aspect are allowed under the terms and conditions of Sololearn.
5th May 2024, 9:22 PM
Ausgrindtube
Ausgrindtube - avatar