Skip to content
Open
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
75 changes: 60 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ Use the copy function below to do the following:
2. Return a copy of the received array
*/

function copy(/*your code here*/){
/*your code here*/
function copy(array){
return [...array];
}


console.log('task 1', copy(originalFlavors));




Expand All @@ -63,9 +65,17 @@ Confirm that an array is exactly 31 flavors. Your function should accept:
For Example: is31Flavors(originalFlavors) will return true if your code is working properly
*/


function is31Flavors(/*your code here*/){
/*your code here*/
/// 1 parameter array
function is31Flavors(array){
if (array.lenght === 31){
return true;
}
else{
return false;
}
//check to see that the lenght of the array is 31
// if it is we return true
//else it is false
}

/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -80,9 +90,13 @@ Use the addFlavor function below to do the following:
For example: addFlavor(originalFlavors, "Rainbow Sherbert") should return the array ["Rainbow Sherbert", "Banana Nut Fudge",..."Vanilla Burnt Almond"]
*/


function addFlavor(/*your code here*/){
//2 parameters array, flavor
function addFlavor(array, "Luffy Flavor"){
/*your code here*/
array.shift("Luffy Flavor");
return array;
// use unshift to add the flavor to the fromt of the array
// return the array
}


Expand All @@ -97,8 +111,13 @@ Use the removeLastFlavor function below to do the following:
For example: running removeLastFlavor(originalFlavors) would return ["Rainbow Sherbert", "Banana Nut Fudge",..."Vanilla"]
*/

function removeLastFlavor(/*your code here*/){
//1 parameter array
function removeLastFlavor(array){
/*your code here*/
array.pop();
return array;
//use the .pop to remove last item
//return the array
}


Expand All @@ -114,8 +133,11 @@ Use the getFlavorByIndex function below to do the following:
For example: running getFlavorByIndex(originalFlavors, 2) would return "Black Walnut", assuming Rainbow Sherbert has been added successfully
*/

function getFlavorByIndex(/*your code here*/){
/*your code here*/
//2 para array and number(i)

function getFlavorByIndex(array, 3){
return.array[3];
//return the array and call the desired index return array[i]
}


Expand All @@ -133,9 +155,19 @@ Use the removeFlavorByName function below to do the following:

HINT: You can use .splice() for this
*/

function removeFlavorByName(/*your code here*/){
/*your code here*/
//2 para array, index(string)

function removeFlavorByName(array, "Maple Nut"){
for (let i = 0; i < array.length; i++) {
if (array[i] === "Maple Nut"){
array.splice(i, 1);
}
}
return array;
// loop thru array
//write a conditional checking to see if the index matches the given flavor
//if it does remve it (splice)
//outside of the loop return the array
}


Expand All @@ -160,8 +192,21 @@ Use the filterByWord function below to do the following:
DO NOT USE ADVANCED ARRAY METHODS (i.e. .filter) to solve this problem.
*/

function filterByWord(/*your code here*/){
//2 para array, (string)
function filterByWord(array, 'Vanilla'){
const filterArray[];
for (let i = 0; i < array.length; i++){
if(array[i].includes('Vanilla')){
filterArray.push(array);
}
}
return filterArray;
/*your code here*/
//create new array called filterArray to push values to
//loop thru the array to check for the desired item (includes "=")
//write a conditional checking if the item is contained
//if item includes string, push to the filterArray
//outside of the for loop retunr the filtered array
}


Expand Down Expand Up @@ -194,7 +239,7 @@ Use the getRandomFlavors function and new arrays below to do the following:
For example: getRandomFlavors(originalFlavors, newFlavors, seasonalFlavors, regionalFlavors) might return ["Strawberry Cheesecake", "Eggnog,"..."Chocolate"].
*/


//move the array above the function
function getRandomFlavors(/*code here*/){
/*code here*/
}
Expand Down