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
57 changes: 47 additions & 10 deletions 01-smacss-media-queries/challenges/challenges-01.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Then, write a function named speaker that takes in a string and a callback funct
------------------------------------------------------------------------------------------------ */

const greeting = (word) => {
// Solution code here...
return word.toUpperCase();
}

const speaker = (message, callback) => {
// Solution code here...
return callback(message);
}

/* ------------------------------------------------------------------------------------------------
Expand All @@ -33,11 +33,14 @@ Return the modified array.
------------------------------------------------------------------------------------------------ */

const addValues = (arr, value) => {
// Solution code here...
arr.push(value);
}

const addNumbers = (num, arr, times, callback) => {
// Solution code here...
for(let i = 0; i < times; i++){
arr.push(num);
}
return arr;
}

/* ------------------------------------------------------------------------------------------------
Expand All @@ -53,11 +56,16 @@ Return the modified array.
------------------------------------------------------------------------------------------------ */

const removeOne = (num, arr) => {
// Solution code here...
if(num % 3 === 2){
arr.pop();
}
}

const removeElements = (arr, callback) => {
// Solution code here...
for (let i = 0; i < arr.length; i++){
callback(arr[i], arr);
}
return arr;
}

/* ------------------------------------------------------------------------------------------------
Expand All @@ -67,7 +75,10 @@ Write a function named removeWithForEach that produces the same output as challe
------------------------------------------------------------------------------------------------ */

const removeWithForEach = (arr, callback) => {
// Solution code here...
arr.forEach((val) => {
callback(val, arr)
})
return arr;
}

/* ------------------------------------------------------------------------------------------------
Expand All @@ -81,7 +92,12 @@ This anonymous function should accept up to three arguments: the element, the in
------------------------------------------------------------------------------------------------ */

const removeWithAnon = (arr) => {
// Solution code here...
arr.forEach((val, index, arr) => {
if(val % 3 === 2){
arr.pop();
}
})
return arr;
}

/* ------------------------------------------------------------------------------------------------
Expand All @@ -102,7 +118,13 @@ This function should use forEach to populate your grocery list based on the stor
------------------------------------------------------------------------------------------------ */

const createList = (availableItems) => {
// Solution code here...
let groceryList = [];
availableItems.forEach((val) => {
if (val.available === true) {
groceryList.push(val.name);
}
})
return groceryList;
}

/* ------------------------------------------------------------------------------------------------
Expand All @@ -120,7 +142,22 @@ Return the resulting output array.
------------------------------------------------------------------------------------------------ */

const fizzbuzz = (arr) => {
// Solution code here...
let output = [];
arr.forEach((val) => {
if ((val % 3 === 0) && (val % 5 === 0)) {
output.push("Fizz Buzz")
}
else if (val % 3 === 0){
output.push("Fizz");
}
else if (val % 5 === 0){
output.push("Buzz");
}
else {
output.push(val);
}
})
return output;
}

/* ------------------------------------------------------------------------------------------------
Expand Down