All Tracks/lab element skipper/
Đang tải...
Hướng dẫn thử thách
1 / 1

Implement an Element Skipper

In this lab you will create a function that skips elements in an array until it finds an acceptable one based on a specific test function. For example, for an array like `[1, 1, 1, 2, 1, 1, 1]` and a test function `function(n) {return n === 2}`, the first element that is acceptable for this is the one at index 3, so all the elements before that need to be discarded, and the output should be the remaining elements `[2, 1, 1, 1]`. **Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab. **User Stories:** 1. You should have a `dropElements` function that accepts an array (`arr`) and a function (`func`) as arguments. 1. The `dropElements` function should iterate through the array and remove elements starting from the first one until `func` returns `true` for an element. 1. The `dropElements` function should return the remaining elements in the array if the condition is met. 1. If the condition is never satisfied, it should return an empty array.
Vượt qua bài kiểm tra hiện tại để mở khóa bài tiếp theo.
main.js
UTF-8 • Tab Size: 2Kiểm tra bài:⌘↵
Test Output
Thử thách này không có bài test tự động. Hãy quan sát kết quả trực tiếp ở khung Preview.