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
226 changes: 128 additions & 98 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ 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(arg){
const newArray = [...arg];
return newArray;
}


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


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


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


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


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


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


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


function getFlavorByIndex(/*your code here*/){
/*your code here*/
function getFlavorByIndex(arg1, arg2){
return arg1[arg2];
}


Expand All @@ -138,8 +140,9 @@ 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(arg1, arg2){
arg1.splice(arg1.indexOf(arg2), 1);
return arg1;
}


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


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


Expand All @@ -181,8 +192,13 @@ Use the getAverageWordLength function below to do the following:
For example: getAverageWordLength(originalFlavors) should return a number between 0 and 3.
*/

function getAverageWordLength(/*code here*/){
/*code here*/
function getAverageWordLength(arg1){
totalWords = 0;
for (let i = 0; i < arg1.length; i++)
{
totalWords += arg1[i].split(" ").length;
}
return (totalWords/arg1.length);
}


Expand All @@ -199,91 +215,105 @@ Use the getRandomFlavors function and new arrays below to do the following:
*/


function getRandomFlavors(/*code here*/){
/*code here*/
function getRandomFlavors(arg1, arg2, arg3, arg4){
const SeasonalFlavors = [arg1, arg2, arg3, arg4]
let randomFlavors = [];
while (randomFlavors.length != 31)
{
let randomSeasonal = SeasonalFlavors[(Math.floor(Math.random() * (SeasonalFlavors.length)))];
let randomValue = randomSeasonal[Math.floor(Math.random() * randomSeasonal.length)];

if (!randomFlavors.includes(randomValue))
{
randomFlavors.push(randomValue);
}
}
return randomFlavors;
}

// NEW DATA ARRAYS FOR STRETCH 2 ⬇️
// const newFlavors = [
// "Date night",
// "U.S.S Butterscotch (Stranger Things special)",
// "Honey Almond",
// "Mint Chocolate Chip",
// "Chocolate",
// "Oreo® Cookies'n Cream",
// "Chocolate Chip",
// "Pralines 'n Cream",
// "Very Berry Strawberry",
// "Chocolate Chip Cookie Dough",
// "Old Fashioned Butter Pecan",
// "Jamoca®",
// "Jamoca® Almond Fudge",
// "Reese's® Peanut Butter Cup",
// "Rocky Road",
// "Peanut Butter ’n Chocolate",
// "Gold Medal Ribbon®",
// "World Class® Chocolate",
// "Cherries Jubilee",
// "Chocolate Fudge",
// "Daiquiri Ice",
// "Rainbow Sherbet",
// "Rainbow Swirl"
// ]

// const seasonalFlavors = [
// "America's Birthday Cake",
// "Baseball Nut®",
// "Blueberry Cheesecake",
// "Bourbon Street Pecan Pie",
// "Brownie Bar Mashup",
// "Cherry Cordial with Kisses",
// "Chocolate Mousse Royale",
// "French Vanilla",
// "Eggnog",
// "German Chocolate Cake",
// "Icing on the Cake",
// "Love Potion #31",
// "New York Cheesecake",
// "Nutty Coconut",
// "Peppermint",
// "Strawberry Cheesecake",
// "Rock ’n Pop Swirl",
// "Reese’s Peanut Butter Cup",
// "Trick Oreo Treat",
// "Winter White Chocolate",
// "made with Snickers®",
// "made with M&M's®",
// "Heath®",
// "Mango Tango"
// ]

// const regionalFlavors = [
// "Pink Bubblegum",
// "Caramel Macchiato",
// "York Peppermint Pattie",
// "Cotton Candy",
// "Orange Sherbet",
// "Grape Ice",
// "Watermelon Ice",
// "Miami Vice Sorbet",
// "Splish Splash®",
// "Wild 'n Reckless Sherbet",
// "Lemon Custard",
// "Oregon Blackberry",
// "Bananas ‘n Strawberries",
// "Mississippi Mud",
// "Rum Raisin",
// "Creole Cream Cheese",
// "Chocolate Almond",
// "Fudge Brownie",
// "Banana Nut",
// "Black Walnut",
// "Cotton Candy Crackle",
// "Quarterback Crunch",
// "Chocolate Chocolate Chip Cheesecake",
// "Caramel 'n' Cookies"
// ]
const newFlavors = [
"Date night",
"U.S.S Butterscotch (Stranger Things special)",
"Honey Almond",
"Mint Chocolate Chip",
"Chocolate",
"Oreo® Cookies'n Cream",
"Chocolate Chip",
"Pralines 'n Cream",
"Very Berry Strawberry",
"Chocolate Chip Cookie Dough",
"Old Fashioned Butter Pecan",
"Jamoca®",
"Jamoca® Almond Fudge",
"Reese's® Peanut Butter Cup",
"Rocky Road",
"Peanut Butter ’n Chocolate",
"Gold Medal Ribbon®",
"World Class® Chocolate",
"Cherries Jubilee",
"Chocolate Fudge",
"Daiquiri Ice",
"Rainbow Sherbet",
"Rainbow Swirl"
]

const seasonalFlavors = [
"America's Birthday Cake",
"Baseball Nut®",
"Blueberry Cheesecake",
"Bourbon Street Pecan Pie",
"Brownie Bar Mashup",
"Cherry Cordial with Kisses",
"Chocolate Mousse Royale",
"French Vanilla",
"Eggnog",
"German Chocolate Cake",
"Icing on the Cake",
"Love Potion #31",
"New York Cheesecake",
"Nutty Coconut",
"Peppermint",
"Strawberry Cheesecake",
"Rock ’n Pop Swirl",
"Reese’s Peanut Butter Cup",
"Trick Oreo Treat",
"Winter White Chocolate",
"made with Snickers®",
"made with M&M's®",
"Heath®",
"Mango Tango"
]

const regionalFlavors = [
"Pink Bubblegum",
"Caramel Macchiato",
"York Peppermint Pattie",
"Cotton Candy",
"Orange Sherbet",
"Grape Ice",
"Watermelon Ice",
"Miami Vice Sorbet",
"Splish Splash®",
"Wild 'n Reckless Sherbet",
"Lemon Custard",
"Oregon Blackberry",
"Bananas ‘n Strawberries",
"Mississippi Mud",
"Rum Raisin",
"Creole Cream Cheese",
"Chocolate Almond",
"Fudge Brownie",
"Banana Nut",
"Black Walnut",
"Cotton Candy Crackle",
"Quarterback Crunch",
"Chocolate Chocolate Chip Cheesecake",
"Caramel 'n' Cookies"
]

const RandomFlavor = getRandomFlavors(originalFlavors, newFlavors, seasonalFlavors, regionalFlavors);
console.log(RandomFlavor);


/* 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 */
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.