Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 392 Bytes

random-integers.md

File metadata and controls

17 lines (12 loc) · 392 Bytes

Random integers

Add in Node.js v14.10.0 is a built-in function for getting a random integer synchronously or asynchronously:

import * as crypto from 'crypto';

console.log(crypto.randomInt(10));
// => 5

// asynchronously
crypto.randomInt(10, console.log);
// => 7

source