Hi everyone ,how to create list inside list in test

i have this code but not work i wanna to get all item and filter this items and put it in new list
he print first list correct but second list not have items

const response = pm.response.json()

let allTracks = response.map(item => item.track);

console.log(allTracks);

for(let i = 0; i < allTracks.length; i++){

if (allTracks[i] != "Software Testing"){

let Tracks = response.map(allTracks[i]); ;

console.log(Tracks);

}

}

Your descriptions of what you want to achieve are not very clear.

It might be a language barrier, but I can’t ascertain what you are trying to achieve so any help will be limited as I’m totally guessing on what you are trying to achieve.

This line though…

let Tracks = response.map(allTracks[i]); ;

allTracks[i] will just be a string with the value of the current track if its not “Software Testing”.

I’m surprised the map function is not returning an error at this point as the command is not complete. Map what to what? You just have a single variable. The map function is incomplete.

What is it you are trying to do?

Do you just want an array of the tracks that are not “Software Testing”?

This can be done using the JavaScript “filter” function.

let allTracks = response.map(item => item.track);
console.log(allTracks);

let tracks = allTracks.filter(track => track != "Software Testing");
console.log(tracks);