Detective, you have 5 people, and they were at the scene of a crime. You are trying to figure out where they were, so you and your team have questioned the 5 suspects. The 5 suspects are: Alice, Bob, Charlie, Daisy, and Ethan. You have got the information but you think that there are some contradictions in what they're saying. For clarity, you and your team have written their statements so that they are all the same format. function compareStatements(people) { You have put each of the suspects and their information into an object as follows: const person1 = { name: 'Alice', statements: [ 'I was in the location', 'Bob was in the place', 'Charlie was not in the spot, 'Daisy was in the zone', 'Ethan was not in the room', ], }; Your objective is to compare the statements, and if any contradict, you want to put them into a nested array as part of a sub array, appending their name to their statement as follows: [['Alice: I was in the location', 'Bob: Alice was not in the location']] and return that array.
function compareStatements(people) { const contradictions = []; people.forEach(person => { person.statements.forEach((statement, index) => { people.forEach(person2 => { if (person.name !== person2.name && !contradictions.includes(person2.statements[index])) { contradictions.push(`${person.name}: ${statement}`, `${person2.name}: ${person2.statements[index]}`); } }); }); }); return contradictions; } const person1 = { name: 'Alice', statements: [ 'I was in the location', 'Bob was in the place', 'Charlie was not in the spot', 'Daisy was in the zone', 'Ethan was not in the room', ], }; const person2 = { name: 'Bob', statements: [ 'I was in the place', 'Alice was not in the location', 'Charlie