Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions practice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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){
Expand All @@ -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){
Expand All @@ -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){
Expand All @@ -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){
Expand All @@ -123,6 +144,11 @@ uniq(names, function(uniqArr){
*/

//Code Here
function each (names, callback) {
for (let i=0; i<names.length; i++) {
callback(names[i], i)
}
}

// Do not edit the code below.
each(names, function(item, indice){
Expand All @@ -140,6 +166,13 @@ each(names, function(item, indice){
*/

// Code here
function getUserById (array, id, callback) {
for (var i = 0; i < array.length; i++) {
if (id == array[i]) {
}
return callback(array[i]);
}
}

// Do not edit the code below.
var users = [
Expand Down
4 changes: 2 additions & 2 deletions user.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "",
"email": ""
"name": "Trizha Kate N. Longaza",
"email": "trizha.longaza@boom.camp"
}