var dl=snake_x; var dt=snake_y; var fl=fd.style.left; var ft=fd.style.top; var dv=document.querySelectorAll("#snake div"); var sk=document.getElementById("snake"); var a2=Number(fl.substring(0,fl.indexOf("px"))); var b2=Number(ft.substring(0,ft.indexOf("px"))); if(Math.abs(dl-a2)<=60&&Math.abs(dt-b2)<=60){ fd.style.left=Math.random()*1000+"px"; fd.style.top=Math.random()*800+"px"; sk.appendChild(dv[1].cloneNode()); boxs = document.querySelectorAll(".box");