+ 2

How can i import math library with the random and floor function

I created a small game which need to import random number

7th Nov 2020, 6:37 AM
Tabot Charles Bessong
2 Respostas
+ 5
If your talking about Javascript, then there is no need to import anything. Its inbuilt. You can access it by Math. ●Random Number There is a function random in Math. Like this, var num = Math.random() This produces a random decimal between 0 and 1. You can multiply that number with 50, if you want to have a random number till 50. For ex. var num = Math.random() * 145 This produces a random number between 0 and 145. This code may produce 10.2828, 78.234, 18.23, 90.36, 144.5, 1.1, etc,etc.... PLEASE ASK IF YOU HAVE ANY DOUBTS
7th Nov 2020, 6:50 AM
Steve Sajeev
Steve Sajeev - avatar
0
I used the same method you stated above but there was an error in the console
7th Nov 2020, 9:40 AM
Tabot Charles Bessong