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

complete #69

Closed
wants to merge 1 commit into from
Closed
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
60 changes: 32 additions & 28 deletions solution.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,76 @@
const { nums, words } = require("./data/data.js");

// Every
const isEveryNumGreaterThan2 = () => {
//
const isEveryNumGreaterThan2 = (arr) => {
return arr.every((e) => e > 2);
};

const isEveryWordShorterThan7 = () => {
//
const isEveryWordShorterThan7 = (arr) => {
return arr.every((e) => e.length < 7);
};

// Filter

const arrayLessThan5 = () => {
//
const arrayLessThan5 = (arr) => {
return arr.filter((e) => e < 5);
};

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

// Find

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

const firstWordLongerThan4Char = () => {
//
const firstWordLongerThan4Char = (arr) => {
return arr.find((e) => e.length > 4);
};

// Find Index

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

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

// For Each

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

const logWordsWithExclamation = () => {
//
const logWordsWithExclamation = (arr) => {
arr.forEach((e) => {
console.log(`${e}!`);
});
};

// Map

const arrayValuesSquaredTimesIndex = () => {
//
const arrayValuesSquaredTimesIndex = (arr) => {
return arr.map((e, i) => Math.pow(e, 2) * i);
};

const arrayWordsUpcased = () => {
//
const arrayWordsUpcased = (arr) => {
return arr.map((e) => e.toUpperCase());
};

// Some

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

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

module.exports = {
Expand Down