Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to get the current iteration count in Postman.
Postman
let currentIteration = pm.info.[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.info.count instead of pm.info.iteration
Using pm.info.index which does not exist
Using pm.info.number which is incorrect
✗ Incorrect
The correct property to get the current iteration count in Postman is pm.info.iteration.
2fill in blank
mediumComplete the code to log the current iteration count in the Postman console.
Postman
console.log('Current iteration:', pm.info.[1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.info.count which is not a valid property
Using pm.info.step or pm.info.cycle which do not exist
✗ Incorrect
pm.info.iteration gives the current iteration count, which can be logged to the console.
3fill in blank
hardFix the error in the code to correctly check if the current iteration is the first one.
Postman
if (pm.info.[1] === 0) { console.log('First iteration'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.info.count which is undefined
Using pm.info.index which is not a valid property
✗ Incorrect
pm.info.iteration starts at 0 for the first iteration, so checking pm.info.iteration === 0 is correct.
4fill in blank
hardFill both blanks to create a loop that runs for the total number of iterations in Postman.
Postman
for (let i = 0; i < pm.info.[1]; i[2]) { console.log('Iteration:', i); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.info.iteration instead of iterations for total iterations
Using i-- which would cause an infinite loop
✗ Incorrect
pm.info.iterations gives the total number of iterations, and i++ increments the loop counter.
5fill in blank
hardFill all three blanks to store the current iteration, total iterations, and check if it is the last iteration.
Postman
let current = pm.info.[1]; let total = pm.info.[2]; if (current === total - [3]) { console.log('Last iteration'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.info.count instead of iterations
Using 0 instead of 1 when subtracting to check last iteration
✗ Incorrect
pm.info.iteration is the current iteration, pm.info.iterations is total iterations, and subtracting 1 checks for the last iteration.