Tell us what’s happening:
Hi plz help. I can’t seem to get past step 4. I keep getting this error “Inside the for loop, you should check for a duplicate id. If one is found, log “Duplicate ID: " + astronaut.id” to the console and then call return to exit the function.”
Your code so far
// User Editable Region
const squad = [];
const firstAstronaut = {
id: 1,
name: "Andy",
role: "Commander",
isEVAEligible: true,
priority: 3
};
function addAstronaut(crew, astronaut) {
for (let i = 0; i < crew.length; i++) {
if (crew[i].id === astronaut.id) {
console.log("Duplicate ID: " + astronaut.id);
return;
}
}
crew.push(astronaut);
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 Edg/150.0.0.0
Challenge Information:
Build a Space Mission Roster - Step 4
