Complete the code to assign a variable named userId with the value 12345 in Postman script.
pm.variables.set('userId', [1]);
In Postman scripts, to assign a string value to a variable, you must put the value in quotes. So '12345' is correct.
Complete the code to retrieve the variable sessionToken from Postman environment variables.
const token = pm.environment.get([1]);When getting a variable in Postman, the variable name must be a string, so it needs quotes.
Fix the error in the code to correctly set a global variable count to 10.
pm.globals.set('count', [1]);
Global variables can hold numbers directly without quotes. Using 10 sets the number correctly.
Fill both blanks to create a local variable status with value active and then retrieve it.
pm.variables.set([1], [2]); const currentStatus = pm.variables.get('status');
Variable names and string values must be in quotes. So 'status' and 'active' are correct.
Fill all three blanks to set an environment variable userRole to admin, then get it and check if it equals admin.
pm.environment.set([1], [2]); const role = pm.environment.get('userRole'); pm.test('Role is admin', () => pm.expect(role).to.eql([3]));
Variable names and string values must be quoted. For the test assertion, double quotes or single quotes work, here double quotes are used.