0
0
Postmantesting~10 mins

Global variables 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 set a global variable named 'token' with value 'abc123'.

Postman
pm.globals.[1]('token', 'abc123');
Drag options to blanks, or click blank then click option'
Aclear
Bget
Cunset
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'set' to assign a value.
Trying to clear a variable instead of setting it.
2fill in blank
medium

Complete the code to retrieve the value of the global variable 'token'.

Postman
const token = pm.globals.[1]('token');
Drag options to blanks, or click blank then click option'
Aset
Bunset
Cget
Dclear
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' instead of 'get' to retrieve a value.
Trying to unset or clear when just reading.
3fill in blank
hard

Fix the error in the code to remove the global variable named 'token'.

Postman
pm.globals.[1]('token');
Drag options to blanks, or click blank then click option'
Aunset
Bget
Cset
Dclear
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'clear' which removes all variables, not just one.
Using 'set' or 'get' instead of 'unset'.
4fill in blank
hard

Fill both blanks to check if the global variable 'token' exists and then remove it.

Postman
if (pm.globals.[1]('token') !== undefined) {
  pm.globals.[2]('token');
}
Drag options to blanks, or click blank then click option'
Aget
Bset
Cunset
Dclear
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' instead of 'get' to check existence.
Using 'clear' which removes all variables instead of one.
5fill in blank
hard

Fill all three blanks to update the global variable 'token' by appending '-updated' to its current value.

Postman
const current = pm.globals.[1]('token');
pm.globals.[2]('token', current [3] '-updated');
Drag options to blanks, or click blank then click option'
Aget
Bset
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' to join strings.
Trying to set before getting the current value.