This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.

Smartphone icons created by Freepik - Flaticon

JS Math

Math.floor(Math.random() * 10) returns a random integer between 0 and 9 (both included):

document.getElementById("demo").innerHTML =
Math.floor(Math.random() * 10);