Complete the code to generate a random integer between 1 and 100 in Postman.
var randomNumber = Math.[1](Math.random() * 100) + 1;
The Math.floor() function rounds down to the nearest integer. Scaling Math.random() * 100 gives 0-99.999, flooring gives 0-99, and adding 1 produces 1-100.
Complete the code to generate a random string of 5 characters using Postman scripting.
var randomString = Math.random().toString(36).[1](2, 7);
The slice method extracts characters from a string between two indices. Here, it extracts 5 characters starting from index 2.
Fix the error in the code to generate a random boolean value in Postman.
var randomBool = Math.random() [1] 0.5;
To get a random boolean, compare if the random decimal is greater than 0.5. Using '=' is assignment and causes error.
Fill both blanks to create a random integer between 10 and 50 inclusive in Postman.
var randomInt = Math.floor(Math.random() * ([1] - [2] + 1)) + [2];
The formula for random integer between min and max is Math.floor(Math.random() * (max - min + 1)) + min. Here, max=50 and min=10.
Fill all three blanks to generate a random hexadecimal color code in Postman.
var color = '#' + Math.floor(Math.random() * [1]).toString([2]).padStart([3], '0');
To generate a hex color code, multiply random by 16777215 (which is 0xFFFFFF), convert to base 16, and pad to 6 characters.