diff --git a/practice.js b/practice.js index a9e0f69..73c50fa 100644 --- a/practice.js +++ b/practice.js @@ -28,6 +28,9 @@ */ // Code Here +function first(array, callback) { + callback(array[0]) + } // Do not edit the code below. var names = ['Aodhan', 'Greg', 'Jake', 'Oscar', 'Aodhan', 'Tanner', 'Greg']; @@ -48,6 +51,9 @@ first(names, function(firstName){ */ //Code Here +function last(array, callback) { + callback(array.slice(-1).pop()); +} // Do not edit the code below. last(names, function(lastName){ @@ -66,6 +72,9 @@ last(names, function(lastName){ */ //Code Here +function multiply(num1, num2, callback) { + callback(num1 * num2); +} // Do not edit the code below. multiply(4, 3, function(answer){ @@ -85,6 +94,14 @@ multiply(4, 3, function(answer){ */ //Code Here +function contains(array, name, callback) { + if (array.includes(name)) { + callback(true); + } + else { + callback(false); + } +} // Do not edit the code below. contains(names, 'Oscar', function(result){ @@ -106,6 +123,10 @@ contains(names, 'Oscar', function(result){ */ //Code Here +function uniq (array, callback) { + var result = [...new Set(array)]; + callback(result); +} // Do not edit the code below. uniq(names, function(uniqArr){ @@ -123,6 +144,11 @@ uniq(names, function(uniqArr){ */ //Code Here +function each (names, callback) { + for (let i=0; i