diff --git a/index.js b/index.js index 66b60b4..2338ede 100644 --- a/index.js +++ b/index.js @@ -14,8 +14,11 @@ */ function find(array, callback) { for (let element of array) { - // Write your code here. + if (callback(element)) { + return element; + } } + return undefined; } /** @@ -35,7 +38,7 @@ function find(array, callback) { function filter(array, callback) { const result = []; for (let element of array) { - // Write your code here. + if(callback(element)) { result.push(element)} } return result; } @@ -57,7 +60,7 @@ function filter(array, callback) { function map(array, callback) { const result = []; for (let element of array) { - // Write your code here. + result.push(callback(element)) } return result; } @@ -77,7 +80,7 @@ function map(array, callback) { */ function forEach(array, callback) { for (let i = 0; i < array.length; i++) { - // Write your code here. + callback(array[i], i,array) } } diff --git a/package-lock.json b/package-lock.json index d4363f5..5c181a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "8-0-higher-order-functions-lab", "version": "1.0.0", "license": "ISC", "devDependencies": {