I'm making a snake game and have hit a stop when generating the food coordinates.
I want a random number that is divisible by 10. By that I mean that it has to be a number mod(10) == 0. The snake is of width 10 so in order for the coordinates to match, I need numbers like 80, 130, 10, 40, 200
Only even numbers without singulars are allowed. This is my current code:
let width = 100;
let height = 100;
let x = Math.floor(Math.random()*width/2)*2;
let y = Math.floor(Math.random()*height/2)*2;
console.log(x + " : " + y);