Step 12 Build a space mission roster is passing code with errors
Describe the Issue
Step 12 shows instructions how to update elements in an array, including by making a shallow copy to not mutate the original array.
The only code needed to pass is:
updatedCrew[fromIndex] = updatedCrew.splice(toIndex, 1, updatedCrew[fromIndex])[0]; An updated copy array isn't strictly needed. However the test also passes with an updated copy:
const updatedCopy = updatedCrew.slice();
More concerning is that the test also passes if the wrong syntax is used to make a copy:
const updatedCopy = updatedCrew.splice();
Affected Page
https://www.freecodecamp.org/learn/javascript-v9/workshop-space-mission-roster/step-12
Your code
const updatedCrew = crew.slice();
const updatedCopy = updatedCrew.splice();
// User Editable Region
updatedCrew[fromIndex] = updatedCrew.splice(toIndex, 1, updatedCrew[fromIndex])[0];
Expected behavior
Can the test be changed to not pass a syntax error when creating a further shallow copy ?
If the instructions require a further additional copy, can they be more explicit on this? Otherwise as a camper has said it is pointless to add it here and on step 13 the code doesn't appear.
Screenshots
n/a
System
- Device: [e.g. iPhone 6, Laptop]
- OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]
Additional context
n/a
Source: freeCodeCamp/freeCodeCamp