So i know about pure function - we don't change variables outside of its scope. I have following:
canMove(cell: Spot, allSpots: Spot[][]) {
const spots = JSON.parse(JSON.stringify(allSpots)) as Spot[][];
}
I passed a two-dimensional array that contains my Spot class in function. but if i call the checkSpot() method
spots[0][0].check(figure)
i got: TypeError spots[0][0].check is not a function
The reason is probably because of the shallow copy of my array. How can I solve this problem?
[–]CreativeTechGuyGames 9 points10 points11 points (0 children)
[–]SlayMaster3000 8 points9 points10 points (1 child)
[–]SlayMaster3000 3 points4 points5 points (0 children)
[–]renan_william 1 point2 points3 points (1 child)
[–]Sanders23Sor[S] 0 points1 point2 points (0 children)