I'm trying build sanke game but my code find this wrong

getRandomFoodPosition( ){
let newFoodPosition
while (newFoodPosition == null || onSnake(newFoodPosition)){
newFoodPosition = randomGridPosition()
return newFoodPosition


in pen you’ll can see the whole food.js https://codepen.io/spoonerboy/pen/wvXdgBE

You are missing something very important if you are trying to declare a function named getRandomFoodPosition here.

Also, you have attempt to export two functions of the same name:

export function update() {
export function draw(gameBoard) {

And what’s the important thing?

AH function, , i get it