March 2019
Intermediate to advanced
208 pages
5h 11m
English
All the functions we’ve written so far have been much like the functions you know from math: they take one or more arguments and return some value. (Similarly, our functions always return the same values for the same inputs—they’re pure functions.)
Some functions don’t require any inputs—the Js.Math.random function doesn’t need any input argument. Calling it will give you back a random number from 0.0 to 1.0, and you’ll get a different one every time. When calling a function with no parameters, you must provide the parentheses after the function name:
| | let random1 = Js.Math.random(); |
| | Js.log(random1); |
| | |
| | let random2 = Js.Math.random; |
| | Js |
Read now
Unlock full access