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

done #65

Closed
wants to merge 1 commit into from
Closed

done #65

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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["nums"]
}
Empty file added data/lol.js
Empty file.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 46 additions & 17 deletions solution.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,91 @@
const { nums, words } = require("./data/data.js");
// const { nums, words } = require("./data/data.js");
const nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0];

const words = [
"The",
"quick",
"brown",
"fox",
"jumps",
"over",
"the",
"lazy",
"dog",
];

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

const isEveryWordShorterThan7 = () => {
//
const isEveryWordShorterThan7 = (words) => {
if (!words) {
return false;
}

return words.every((word) => word.length < 7);
};

// Filter

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

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

// Find

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

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

// For Each

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

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

// Map

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

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

// Some

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

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

module.exports = {
Expand Down