Skip to content

Commit

Permalink
saving work
Browse files Browse the repository at this point in the history
  • Loading branch information
TeyPeyPey committed Feb 3, 2025
1 parent af44aee commit e89874c
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,45 @@
//////////////////////////////////////////////////////////////////////
// Step 1 - Search ///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

function search(array, string) {
for (var i = 0; i < array.length; i++){
if(array[i].name === string){
return array[i];
}
}
return null;
}


//////////////////////////////////////////////////////////////////////
// Step 2 - Replace //////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

function replace(animals, name, replacement){
for (var i = 0; i < animals.length; i++){
if(animals[i].name === name){
animals[i] = replacement;
}
}
return;
}


//////////////////////////////////////////////////////////////////////
// Step 3 - Remove ///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

function remove(animals, name){
var newArr = animals.filter(animal => animal.name !== name);
animals.length = 0;
animals.push(newArr);
}


//////////////////////////////////////////////////////////////////////
// Step 4 - Add ///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

function add(animals, animal){

}


/**
Expand Down

0 comments on commit e89874c

Please sign in to comment.