diff --git a/solution.js b/solution.js index 049257f..fb07174 100644 --- a/solution.js +++ b/solution.js @@ -2,72 +2,72 @@ const { nums, words } = require("./data/data.js"); // Every const isEveryNumGreaterThan2 = () => { - // -}; - -const isEveryWordShorterThan7 = () => { - // -}; - -// Filter - -const arrayLessThan5 = () => { - // -}; - -const arrayOddLengthWords = () => { - // -}; - -// Find - -const firstValDivisibleBy4 = () => { - // -}; - -const firstWordLongerThan4Char = () => { - // -}; - -// Find Index - -const firstNumIndexDivisibleBy3 = () => { - // -}; - -const firstWordIndexLessThan2Char = () => { - // -}; - -// For Each - -const logValuesTimes3 = () => { - // -}; - -const logWordsWithExclamation = () => { - // -}; - -// Map - -const arrayValuesSquaredTimesIndex = () => { - // -}; - -const arrayWordsUpcased = () => { - // -}; - -// Some - -const areSomeNumsDivisibleBy7 = () => { - // -}; - -const doSomeWordsHaveAnA = () => { - // -}; + return nums.every(num => num > 2) + }; + + const isEveryWordShorterThan7 = () => { + return words.every(word => word.length < 7) + }; + + // Filter + + const arrayLessThan5 = () => { + return nums.filter(num => num < 5) + }; + + const arrayOddLengthWords = () => { + return words.filter(word => word.length % 2 != 0) + }; + + // Find + + const firstValDivisibleBy4 = () => { + return nums.find(num => num % 4 == 0) + }; + + const firstWordLongerThan4Char = () => { + return words.find(word => word.length > 4) + }; + + // Find Index + + const firstNumIndexDivisibleBy3 = () => { + return nums.findIndex(num => num % 3 == 0) + }; + + const firstWordIndexLessThan2Char = () => { + return words.findIndex(word => word.length < 2) + }; + + // For Each + + const logValuesTimes3 = () => { + return nums.forEach(num => console.log(num * 3)) + }; + + const logWordsWithExclamation = () => { + return words.forEach(word => console.log(word + '!')) + }; + + // Map + + const arrayValuesSquaredTimesIndex = () => { + return nums.map((num, i) => (num ** 2) * i) + }; + + const arrayWordsUpcased = () => { + return words.map(word => word.toUpperCase()) + }; + + // Some + + const areSomeNumsDivisibleBy7 = () => { + return nums.some(num => num % 7 == 0) + }; + + const doSomeWordsHaveAnA = () => { + return words.some(word => word.includes('a')) + }; module.exports = { isEveryNumGreaterThan2,