MCPcopy
hub / github.com/ampproject/amphtml / range

Function range

build-system/server/app.js:681–686  ·  view source on GitHub ↗

* Generate a random number between min and max * Value is inclusive of both min and max values. * * @param {number} min * @param {number} max * @return {number}

(min, max)

Source from the content-addressed store, hash-verified

679 * @return {number}
680 */
681function range(min, max) {
682 const values = Array.apply(null, new Array(max - min + 1)).map(
683 (_, i) => min + i
684 );
685 return values[Math.round(Math.random() * (max - min))];
686}
687
688/**
689 * Returns the result of a coin flip, true or false

Callers 2

getLiveBlogItemFunction · 0.85

Calls 1

applyMethod · 0.80

Tested by

no test coverage detected