Dynamic destructing question

function truthCheck(collection, pre) {

  let arr = [];
  let value;
  let are;

  // '\"${pre}\"'

  for (let i = 0; i < collection.length; i++){
    ( {"sex": value} = collection[i]);
    arr.push(value);
    console.log(value);

  }

  return arr;

}

This statement:

console.log(truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex"));

returns:

[ 'male', 'male', 'female', 'female' ]

How do I allow “sex” to be dynamically inserted using the “per” variable. Is it possible?

You’ll want to put ``` on the lines before and after your code so that it is correctly formatted and readable.

Thanks. I made those changes.