From 2abcf70292bc35c761234030fad5c563572ea1de Mon Sep 17 00:00:00 2001 From: arupay Date: Fri, 23 Sep 2022 12:37:47 -0400 Subject: [PATCH] complete --- solution.js | 60 ++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/solution.js b/solution.js index 049257f..7394d52 100644 --- a/solution.js +++ b/solution.js @@ -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 = {