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
36 changes: 35 additions & 1 deletion practice.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
5/*
Once you complete a problem, refresh ./SpecRunner.html in your browser and check to see if the problem's test(s) are passing.
Passed tests will be indicated by a green circle.
Failed tests will be indicated by a red X.
Expand Down Expand Up @@ -28,6 +28,9 @@
*/

// Code Here
function first(names, cb){
return cb(names[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(names, cb){
return cb(names[names.length-1]);
}

// Do not edit the code below.
last(names, function(lastName){
Expand All @@ -66,6 +72,9 @@ last(names, function(lastName){
*/

//Code Here
function multiply(a,b,cb){
return cb(a*b);
}

// Do not edit the code below.
multiply(4, 3, function(answer){
Expand All @@ -85,6 +94,12 @@ multiply(4, 3, function(answer){
*/

//Code Here
function contains(array, name, cb){
for(let x=0; x<=array.length;x++){
return (array[x]===name) ? cb(true):cb(false);
}
}


// Do not edit the code below.
contains(names, 'Oscar', function(result){
Expand All @@ -107,6 +122,11 @@ contains(names, 'Oscar', function(result){

//Code Here

function uniq(arr, cb){
var newArr= Array.from(new Set(arr))
cb(newArr);
}

// Do not edit the code below.
uniq(names, function(uniqArr){
console.log('The new names array with all the duplicate items removed is ', uniqArr);
Expand All @@ -123,6 +143,12 @@ uniq(names, function(uniqArr){
*/

//Code Here
function each(names, cb){
names.forEach(name =>{
return cb(name, name.indexOf(name))
});
}


// Do not edit the code below.
each(names, function(item, indice){
Expand All @@ -141,6 +167,14 @@ each(names, function(item, indice){

// Code here

function getUserById(user_obj, id, cb){
for(let i = 0; i<=user_obj.length;i++){
if(user_obj[i].id === id){
return cb(user_obj[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": "Martin Earl Raquion",
"email": "martin.raquion@boom.camp"
}