Unexpected variable changes

a student of mine has been trying to recreate snake outside of a grid
to do this he is trying to store an array from the previous frame. but its being changed from something we cant figure out
the code is:
console.log("sp2= "+sp2);


console.log("sp2= "+sp2);


whats supposed to happen is the same number gets logged twice
but what actually happens is two different numbers get logged
and we tried using 2 different variables that should be the same getting logged but it was still different