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

8.4-array-method-drills #108

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
42 changes: 28 additions & 14 deletions solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,85 @@ const { nums, words } = require("./data/data.js");

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

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

// Filter

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

const arrayOddLengthWords = () => {
//
let result = words.filter((f) => f.length % 2 !== 0);
return result;
};

// Find

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

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

// Find Index

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

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

// For Each

const logValuesTimes3 = () => {
//
let result = nums.forEach((e) => e * 3);
return result;
};

const logWordsWithExclamation = () => {
//
let result = words.forEach((e) => e.includes("!"));
return result;
};

// Map

const arrayValuesSquaredTimesIndex = () => {
//
let result = nums.map((m, i) => (m ** 2) * i);
return result;
};

const arrayWordsUpcased = () => {
//
let result = words.map((m) => m.toUpperCase());
return result;
};

// Some

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

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

module.exports = {
Expand Down