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

Passes all test #18

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
88 changes: 44 additions & 44 deletions solution.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
const { nums, words } = require("./data/data.js");

// Every
const isEveryNumGreaterThan2 = () => {
//
};
function isEveryNumGreaterThan2(nums) {
return nums.every((number) => number >= 2);
}

const isEveryWordShorterThan7 = () => {
//
};
function isEveryWordShorterThan7(words) {
return words.every((word) => word.length < 7);
}

// Filter

const arrayLessThan5 = () => {
//
const arrayLessThan5 = (nums) => {
return nums.filter((number) => number < 5);
};

const arrayOddLengthWords = () => {
//
const arrayOddLengthWords = (words) => {
return words.filter((word) => word.length % 2 === 1);
};

// Find

const firstValDivisibleBy4 = () => {
//
const firstValDivisibleBy4 = (nums) => {
return nums.find((number) => number % 4 === 0);
};

const firstWordLongerThan4Char = () => {
//
const firstWordLongerThan4Char = (words) => {
return words.find((word) => word.length > 4);
};

// Find Index

const firstNumIndexDivisibleBy3 = () => {
//
const firstNumIndexDivisibleBy3 = (nums) => {
return nums.findIndex((number) => number % 3 === 0);
};

const firstWordIndexLessThan2Char = () => {
//
const firstWordIndexLessThan2Char = (words) => {
return words.findIndex((word) => word.length < 2);
};

// For Each

const logValuesTimes3 = () => {
//
const logValuesTimes3 = (nums) => {
nums.forEach((number) => console.log(number * 3));
};

const logWordsWithExclamation = () => {
//
const logWordsWithExclamation = (words) => {
words.forEach((word) => console.log(word + "!"));
};

// Map

const arrayValuesSquaredTimesIndex = () => {
//
const arrayValuesSquaredTimesIndex = (nums) => {
return nums.map((number, i) => number * number * i);
};

const arrayWordsUpcased = () => {
//
const arrayWordsUpcased = (words) => {
return words.map((word) => word.toUpperCase());
};

// Some

const areSomeNumsDivisibleBy7 = () => {
//
const areSomeNumsDivisibleBy7 = (nums) => {
return nums.some((number) => number % 7 === 0);
};

const doSomeWordsHaveAnA = () => {
//
const doSomeWordsHaveAnA = (words) => {
return words.some((word) => word.includes("a"));
};

module.exports = {
isEveryNumGreaterThan2,
isEveryWordShorterThan7,
arrayLessThan5,
arrayOddLengthWords,
firstValDivisibleBy4,
firstWordLongerThan4Char,
firstNumIndexDivisibleBy3,
firstWordIndexLessThan2Char,
logValuesTimes3,
logWordsWithExclamation,
arrayValuesSquaredTimesIndex,
arrayWordsUpcased,
areSomeNumsDivisibleBy7,
doSomeWordsHaveAnA,
isEveryNumGreaterThan2,
isEveryWordShorterThan7,
arrayLessThan5,
arrayOddLengthWords,
firstValDivisibleBy4,
firstWordLongerThan4Char,
firstNumIndexDivisibleBy3,
firstWordIndexLessThan2Char,
logValuesTimes3,
logWordsWithExclamation,
arrayValuesSquaredTimesIndex,
arrayWordsUpcased,
areSomeNumsDivisibleBy7,
doSomeWordsHaveAnA,
};