Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed coursework #269

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
42 changes: 27 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ Use the copy function below to do the following:
*/


function copy(/*your code here*/){
/*your code here*/
function copy(repFlavors){
const copiedFlavors = [...originalFlavors]
return(copiedFlavors)
}


Expand All @@ -63,9 +64,9 @@ For Example: is31Flavors(originalFlavors) will return true if your code is worki
*/


function is31Flavors(/*your code here*/){
/*your code here*/
}
function is31Flavors(array31){
return(array31.length === 31)
}



Expand All @@ -82,8 +83,10 @@ Use the addFlavor function below to do the following:
*/


function addFlavor(/*your code here*/){
/*your code here*/
function addFlavor(oldFlavors,myFlavor){
// oldFlavors = [...originalFlavors]
oldFlavors.unshift(myFlavor)
return(oldFlavors)
}


Expand All @@ -100,8 +103,9 @@ Use the removeLastFlavor function below to do the following:
*/


function removeLastFlavor(/*your code here*/){
/*your code here*/
function removeLastFlavor(rmflavor){
rmflavor.pop()
return(rmflavor)
}


Expand All @@ -118,8 +122,8 @@ Use the getFlavorByIndex function below to do the following:
*/


function getFlavorByIndex(/*your code here*/){
/*your code here*/
function getFlavorByIndex(ar,ind){
return(ar[ind])
}


Expand All @@ -138,8 +142,10 @@ Use the removeFlavorByName function below to do the following:
HINT: You can use .splice() for this
*/

function removeFlavorByName(/*your code here*/){
/*your code here*/
function removeFlavorByName(ar,str){
const deleteFlavor = ar.indexOf(str)
ar.splice(deleteFlavor,1)
return(ar)
}


Expand All @@ -163,8 +169,14 @@ Use the filterByWord function below to do the following:
*/


function filterByWord(/*your code here*/){
/*your code here*/
function filterByWord(ar,str){
const filterFlavors = []
for(let i = 0; i < ar.length;i++){
if(ar[i].includes(str)){
filterFlavors.push(ar[i])
}
}
return(filterFlavors)
}


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.