0
0
Postmantesting~10 mins

Looping in flows 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 start a loop over an array of items in Postman test script.

Postman
for (let [1] = 0; [1] < items.length; [1]++) {
    console.log(items[[1]]);
}
Drag options to blanks, or click blank then click option'
Acount
Bi
Citem
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not consistent in all parts of the loop.
Using a variable name that is not declared with let.
2fill in blank
medium

Complete the code to loop through an array and check if each response status is 200.

Postman
pm.test('Status is 200 for item ' + [1], function () {
    pm.expect(responses[[1]].code).to.eql(200);
});
Drag options to blanks, or click blank then click option'
Ai
Bresponse
Cindex
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable that is not defined in the loop.
Using the whole item object instead of the index.
3fill in blank
hard

Fix the error in the loop that tries to iterate over an array of responses but uses wrong syntax.

Postman
for (let i = 0; i [1] responses.length; i++) {
    pm.expect(responses[i].code).to.eql(200);
}
Drag options to blanks, or click blank then click option'
A<
B>
C<=
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= instead of < in the loop condition.
Using > or >= which will not loop correctly.
4fill in blank
hard

Fill both blanks to create a loop that logs the name and status of each response in Postman.

Postman
for (let [1] = 0; [1] [2] responses.length; [1]++) {
    console.log(responses[[1]].name + ': ' + responses[[1]].status);
}
Drag options to blanks, or click blank then click option'
Ai
B<
C<=
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= in the condition causing index errors.
Using inconsistent variable names.
5fill in blank
hard

Fill all three blanks to create a loop that tests each response code and logs a pass or fail message.

Postman
for (let [1] = 0; [1] [2] responses.length; [1]++) {
    pm.test(`Response [3] status is 200`, function () {
        pm.expect(responses[[1]].code).to.eql(200);
    });
}
Drag options to blanks, or click blank then click option'
Ai
B<
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in the loop and inside the test.
Using <= instead of < in the loop condition.