Index matching an nested dynamic property value

Is there a way to define data[1] as a variable rather than hardcode, then return a true or false once all indexes has been checked and app_ssh is found or not ?

if (query8_userGroups.data[1].profile.name == "app_ssh") { return "true";
} else {
  return "false";
 }
![Screenshot 2023-10-14 at 6.28.27 pm|690x374](upload://iF4CmcNkfPg4sg0F6WSskKa7nFm.png)

Hey @Louis!

Is this in a JS query? Would something like this work? This assumes that query8_userGroups.data[1] is an array:

const data = query8_userGroups.data[1];
const found = data.some(item => item.profile.name == "app_ssh");
return found;

thank you @victoria yes that worked.