# Build a Space Mission Roster - Step 12

**URL:** <https://forum.freecodecamp.org/t/build-a-space-mission-roster-step-12/801577>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [October 2, 2026, 11:30am UTC](https://forum.freecodecamp.org/t/build-a-space-mission-roster-step-12/801577 "2026-10-02T11:30:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michelle-Mungai](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/michelle-mungai/32/422239_2.png) [@Michelle-Mungai](https://forum.freecodecamp.org/u/Michelle-Mungai)\
**Post date:** [October 2, 2026, 11:30am UTC](https://forum.freecodecamp.org/t/build-a-space-mission-roster-step-12/801577/1 "2026-10-02T11:30:41Z")

</div>

### Tell us what’s happening:

I have done what the instructions are saying but I am getting this error:  
2. You should call splice() with the updatedCrew array to perform the swap. You should use the one-line technique.

my code:  
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.

### Your code so far

```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);
}

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]);
}

function swapCrewMembers(crew, fromIndex, toIndex) {
  if (
    fromIndex < 0 || 
    toIndex < 0 ||
    fromIndex >= crew.length ||
    toIndex >= crew.length
  ) {
    console.log("Invalid crew indices");
    return;
  }

  const updatedCrew = crew.slice();
// User Editable Region
updatedCrew[fromIndex] = updatedCrew.splice(toIndex, 1, updatedCrew[fromIndex])[0];
  console.log(updatedCrew);
// User Editable Region
  return updatedCrew;
}

```

### Your browser information:

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36`

### Challenge Information:

Build a Space Mission Roster - Step 12

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-v9/workshop-space-mission-roster/step-12)**
>
> Learn to Code for Free

GitHub Link: [freeCodeCamp/curriculum/challenges/english/blocks/workshop-space-mission-roster/694d8ddd106340237efb0c80.md at main · freeCodeCamp/freeCodeCamp · GitHub](https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/workshop-space-mission-roster/694d8ddd106340237efb0c80.md)

---

<div class="post-metadata">

**Author:** ![dhess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dhess/32/406235_2.png) [@dhess](https://forum.freecodecamp.org/u/dhess)\
**Post date:** [October 2, 2026, 12:16pm UTC](https://forum.freecodecamp.org/t/build-a-space-mission-roster-step-12/801577/2 "2026-10-02T12:16:31Z")

</div>

Welcome to the forum @Michelle-Mungai,

> [@Michelle-Mungai](#):
>
> ```auto
> console.log(updatedCrew);
> // User Editable Region
> return updatedCrew;
> 
> ```

Were you asked to log or return in this step?

Happy coding

---

<div class="post-metadata">

**Author:** ![Michelle-Mungai](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/michelle-mungai/32/422239_2.png) [@Michelle-Mungai](https://forum.freecodecamp.org/u/Michelle-Mungai)\
**Post date:** [October 2, 2026, 12:18pm UTC](https://forum.freecodecamp.org/t/build-a-space-mission-roster-step-12/801577/3 "2026-10-02T12:18:20Z")

</div>

None of the above, thank you for that.

I have removed the return and the code has now worked!
