I am learning JS and have a task to complete which is quite confusing. The task is to giving a index to start from and include the remainders or the the items missing in the array, as well as to display them in angular. This is what i have
const arr = ["a", "b" ,"c" ,"d"]
const startIndex = 2:
let arr2 = arr.slice(startIndex, arr.length)
Output
["c","d"]
// a and b are ignore and don't see a way to display them accordingly
The tasks is to start let’s say at index 2 through the last item and include items a and b which are the items missing when using slice method
2
Answers
Heres an example with your code above:
JS
The … is the spread operator, it allows an iterable (like an array expression) to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected.
Angular Example:
You could use the original array copied twice: