O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

random — Generate a random integer

Usage

Lang.random(range)

range : Number

Description

Returns a random integer that is greater than or equal to zero, and less than or equal to range. If range is a floating-point value, Float.int( ) converts it to an integer first.

The random values are approximately uniformly distributed over the full range, but they shouldn’t be relied on if security is important.

If range is zero, returns zero; if range is less than zero, returns invalid.

Examples

Lang.random(23)

returns an integer between 0 and 23 inclusive

Lang.random(17.2)

returns an integer between 0 and 17 inclusive

Lang.random("foo")

returns invalid

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required