1.4 KiB
1.4 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
9d7123c8c441eeafaeb5bdef | Remove Elements from an Array Using slice Instead of splice | 1 |
Description
undefined
Instructions
undefined
Tests
tests:
- text: ''
testString: 'assert(code.match(/\.slice/g), "Your code should use the <code>slice</code> method.");'
- text: ''
testString: 'assert(!code.match(/\.splice/g), "Your code should not use the <code>splice</code> method.");'
- text: ''
testString: 'assert(JSON.stringify(inputCities) === JSON.stringify(["Chicago", "Delhi", "Islamabad", "London", "Berlin"]), "The <code>inputCities</code> array should not change.");'
- text: ''
testString: 'assert(JSON.stringify(nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])) === JSON.stringify(["Chicago", "Delhi", "Islamabad"]), "<code>nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])</code> should return <code>["Chicago", "Delhi", "Islamabad"]</code>.");'
Challenge Seed
function nonMutatingSplice(cities) {
// Add your code below this line
return cities.splice(3);
// Add your code above this line
}
var inputCities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
nonMutatingSplice(inputCities);
Solution
// solution required