Back to Freecodecamp

Step 8

curriculum/challenges/english/blocks/workshop-space-mission-roster/6951cfd4955dbb84cb9b8b22.md

latest2.9 KB
Original Source

--description--

You had previously added a console.log() call to your addCrewMember function to validate its behavior, and now the call is no longer needed. To prevent the terminal from getting cluttered in future steps, go ahead and remove the current console.log() call.

--hints--

Remove the console.log() call from your addCrewMember function. You should delete the entire line.

js
const solution = (`constsquad=[];constfirstAstronaut={id:1,name:"Andy",role:"Commander",isEVAEligible:true,priority:3};functionaddCrewMember(crew,astronaut){for(leti=0;i<crew.length;i++){if(crew[i].id===astronaut.id){console.log("DuplicateID:"+astronaut.id);return;}}crew.push(astronaut);}addCrewMember(squad,firstAstronaut);constremainingCrew=[{id:2,name:"Bart",role:"Pilot",isEVAEligible:false,priority:8},{id:3,name:"Caroline",role:"Engineer",isEVAEligible:true,priority:4},{id:4,name:"Diego",role:"Scientist",isEVAEligible:false,priority:1},{id:5,name:"Elise",role:"Medic",isEVAEligible:true,priority:7},{id:6,name:"Felix",role:"Navigator",isEVAEligible:true,priority:6},{id:7,name:"Gertrude",role:"Communications",isEVAEligible:false,priority:4},{id:8,name:"Hank",role:"Mechanic",isEVAEligible:true,priority:2},{id:9,name:"Irene",role:"Specialist",isEVAEligible:true,priority:5},{id:10,name:"Joan",role:"Technician",isEVAEligible:false,priority:1},];for(leti=0;i<remainingCrew.length;i++){addCrewMember(squad,remainingCrew[i]);}`);
const cleaned = __helpers.removeWhiteSpace(__helpers.removeJSComments(code));
assert.strictEqual(cleaned, solution);

--seed--

--seed-contents--

js
const squad = [];

const firstAstronaut = {
  id: 1,
  name: "Andy",
  role: "Commander",
  isEVAEligible: true,
  priority: 3
};
function addCrewMember(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);
--fcc-editable-region--
console.log(`Added ${astronaut.name} as ${astronaut.role}`);
--fcc-editable-region--
}
addCrewMember(squad, firstAstronaut);

const remainingCrew = [
  { id: 2, name: "Bart", role: "Pilot", isEVAEligible: false, priority: 8 },
  { id: 3, name: "Caroline", role: "Engineer", isEVAEligible: true, priority: 4 },
  { id: 4, name: "Diego", role: "Scientist", isEVAEligible: false, priority: 1 },
  { id: 5, name: "Elise", role: "Medic", isEVAEligible: true, priority: 7 },
  { id: 6, name: "Felix", role: "Navigator", isEVAEligible: true, priority: 6 },
  { id: 7, name: "Gertrude", role: "Communications", isEVAEligible: false, priority: 4 },
  { id: 8, name: "Hank", role: "Mechanic", isEVAEligible: true, priority: 2 },
  { id: 9, name: "Irene", role: "Specialist", isEVAEligible: true, priority: 5 },
  { id: 10, name: "Joan", role: "Technician", isEVAEligible: false, priority: 1 },
]; 

for (let i = 0; i < remainingCrew.length; i++) {
  addCrewMember(squad, remainingCrew[i]);
}