Unable to generate object on the map

I am trying to make a snake game and was trying to randomly place the food item on the canvas map. However, the snake’s food item is not being generated on the map for some reason and do not get why. How to fix?
Code: https://codepen.io/umalik1910/pen/oJJGZx

3 posts were merged into an existing topic: Struggling with snake game