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

All test passed #102

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

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

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

// Filter

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

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

// Find

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

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

// Find Index

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

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

// For Each

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

const logWordsWithExclamation = () => {
const logWordsWithExclamation = (words) => {
let logExclamations = words.forEach((word) => console.log(word + "!"));
return logExclamations;
//
};

// Map

const arrayValuesSquaredTimesIndex = () => {
const arrayValuesSquaredTimesIndex = (nums) => {
let valuesSquaredTimesIndex = nums.map((num, index) => num * num * index);
return valuesSquaredTimesIndex;
//
};

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

// Some

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

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

Expand Down