0
0
Postmantesting~10 mins

Random data generation in Postman - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to generate a random integer between 1 and 100 in Postman.

Postman
var randomNumber = Math.[1](Math.random() * 100) + 1;
Drag options to blanks, or click blank then click option'
Arandom
Bceil
CrandomInt
Dfloor
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'random' which returns a decimal, not an integer
Choosing 'ceil' which rounds up
Choosing 'randomInt' which does not exist
2fill in blank
medium

Complete the code to generate a random string of 5 characters using Postman scripting.

Postman
var randomString = Math.random().toString(36).[1](2, 7);
Drag options to blanks, or click blank then click option'
Asubstring
Bslice
Csubstr
Dsplit
Attempts:
3 left
💡 Hint
Common Mistakes
Using split which returns an array
Using substring with incorrect indices
3fill in blank
hard

Fix the error in the code to generate a random boolean value in Postman.

Postman
var randomBool = Math.random() [1] 0.5;
Drag options to blanks, or click blank then click option'
A>
B=
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which assigns instead of compares
Using '==' which checks equality but is less clear here
4fill in blank
hard

Fill both blanks to create a random integer between 10 and 50 inclusive in Postman.

Postman
var randomInt = Math.floor(Math.random() * ([1] - [2] + 1)) + [2];
Drag options to blanks, or click blank then click option'
A50
B10
C40
D60
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping min and max values
Forgetting to add 1 in the range calculation
5fill in blank
hard

Fill all three blanks to generate a random hexadecimal color code in Postman.

Postman
var color = '#' + Math.floor(Math.random() * [1]).toString([2]).padStart([3], '0');
Drag options to blanks, or click blank then click option'
A16777215
B16
C6
D255
Attempts:
3 left
💡 Hint
Common Mistakes
Using 255 instead of 16777215 for max value
Using base 10 instead of base 16 for conversion
Not padding the string to 6 characters