Random number

For generating a random number i used this code

 random(10); 

but it generated a number between 10 and 0, but i don’t want it to chose the 0

i’ve found a tutorial where i could use this

 Math.floor(Math.random() * (11 - 1)) + 1 

but sometimes didn’t work so well !!