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

Update index.js #287

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


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

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


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -62,13 +62,15 @@ 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*/
function is31Flavors(array){
if(array.length === 31){
return true;
}else{
return false;
}
console.log('task 2:', flavors(originalFlavors));




/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Corporate has come to you with an idea for a new flavor: Rainbow Sherbert! They think this will be a game changer. You need to modify the array to include this flavor.

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


function addFlavor(/*your code here*/){
/*your code here*/
function addFlavor(array, string){
array.unshift(string)
return array;
}

console.log ('task 3:' addFlavor(originalFlavors, 'Rainbow Sherbert'));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -100,10 +103,11 @@ Use the removeLastFlavor function below to do the following:
*/


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

console.log('task 4:' removeLastFlavor(originalFlavors));


/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Expand All @@ -118,9 +122,10 @@ Use the getFlavorByIndex function below to do the following:
*/


function getFlavorByIndex(/*your code here*/){
/*your code here*/
function getFlavorByIndex(array Number){
return array[number];
}
console.log('task 5:', getFlavorByIndex(originalFlavors, 2));



Expand All @@ -138,9 +143,15 @@ 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(array, flavor){
for (let i = 0; i < array.length; i++){
if(array [i] === flavor){
array.splice(i, 1)
}
}
return array;
}
cpnsole.log('task 6:', removeFlavorByName(originalFlavors, 'Rocky Road'));



Expand All @@ -163,9 +174,15 @@ Use the filterByWord function below to do the following:
*/


function filterByWord(/*your code here*/){
/*your code here*/
function filterByWord(array, flavor){
let filtered array = [];
for (let i = 0; i < array.length; i++){
if (array [i] includes(flavor)){
}
}
return filtered array;
console.log('task 7:' filterByWord(originalFlavor, 'Chocolate'));




Expand Down