As a javascript beginner, I’m struggling a little to get my head around a function I need postman to perform.
I have an array of 15 random numbers, I need to pick 5 numbers from this and send with a postman POST request, but each time I send the number I must include the last number picked ( I.e 1 then 1,2 then 1,2,3, etc)
I know I need to utilise the get next request function in postman to move on when all 5 numbers have been picked.
While I know the javascript I would use to do this if I were just to send this into the console on a browser and have it return the numbers I could use, I have no idea how to put this into the test tabs in postman so I can use the runner and run through the request from start to end and have it move on when complete.
Below is the javascript I have been playing with just for reference:
var myArray = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; //Setting the array.
var newArray = myArray.sort(() => Math.random() - 0.5); //randomise the array.
let contPicks = myArray.slice(0, 5); //pick first 5 values from the shuffled array
let pickOne = contPicks.slice(0,1);
let pickTwo = contPicks.slice(0,2);
let pickThree = contPicks.slice(0,3);
let pickFour = contPicks.slice(0,4);
let pickFive = contPicks.slice(0,5);
It’s probably not the most efficient way of doing this, as I said, I’m a beginner and while I understand the syntax, applying it is another thing entirely! lol