Complete the code to set a collection variable named 'token' with value 'abc123'.
pm.collectionVariables.set('[1]', 'abc123');
The collection variable name is 'token'. This code sets it to 'abc123'.
Complete the code to get the value of the collection variable 'userId'.
const userId = pm.collectionVariables.get('[1]');
To get the value of the collection variable 'userId', use pm.collectionVariables.get('userId').
Fix the error in the code to correctly delete the collection variable named 'sessionId'.
pm.collectionVariables.[1]('sessionId');
The correct method to delete a collection variable is delete. So use pm.collectionVariables.delete('sessionId').
Fill both blanks to check if the collection variable 'token' exists and then log its value.
if (pm.collectionVariables.[1]('[2]')) { console.log(pm.collectionVariables.get('token')); }
The method to check if a collection variable exists is has. The variable name is 'token'.
Fill all three blanks to update the collection variable 'count' by increasing its value by 1.
let current = parseInt(pm.collectionVariables.get('[1]')) || 0; current = current [2] 1; pm.collectionVariables.set('[3]', current.toString());
We get the 'count' variable, add 1 using '+', then set it back to 'count'.