can anyone help me find the bug?
When I run this part of the code, both originalArray and gridArray both output nothing, even though I defined it above, and still ran function add console.log(originalArray) console.log(gridArray) if(originalArray !== gridArray){ console.log("hi"); add(1); And this is above, where I defined the 2 variables: function move(dir) { var originalArray = [gridArray]; //I had to make originalArray a array for the code to work //may change gridArray ... console.log(originalArray) console.log(gridArray) if(originalArray !== gridArray){ console.log("hi"); add(1); } } And also, if you do: console.log(originalArray + "") console.log(gridArray + "") if(originalArray !== gridArray){ console.log("hi"); add(1); } } the originalArray and gridArray will output and shows that originalArray is still changing itself to gridArray even though I did not set it so originalArray would change, and then it will also still broadcast "hi" and run the function add, like if the if is not there somehow. here's the link to my code: https://code.sololearn.com/WZPrRV1jhl76/#html