Skip to content

Commit dba5cec

Browse files
committed
completed lab
1 parent da373ac commit dba5cec

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

solution.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,63 @@ const { nums, words } = require("./data/data.js");
22

33
// Every
44
const isEveryNumGreaterThan2 = () => {
5-
//
5+
return nums.every((num) => num >= 2);
66
};
77

88
const isEveryWordShorterThan7 = () => {
9-
//
9+
return words.every((word) => word.length < 7);
1010
};
1111

1212
// Filter
1313

1414
const arrayLessThan5 = () => {
15-
//
15+
return nums.filter((num) => num < 5);
1616
};
1717

1818
const arrayOddLengthWords = () => {
19-
//
19+
return words.filter((word) => word.length % 2 === 1);
2020
};
2121

2222
// Find
2323

2424
const firstValDivisibleBy4 = () => {
25-
//
25+
return nums.find((num) => num % 4 === 0);
2626
};
2727

2828
const firstWordLongerThan4Char = () => {
29-
//
29+
return words.find((word) => word.length > 4);
3030
};
3131

3232
// For Each
3333

3434
const logValuesTimes3 = () => {
35-
//
35+
return nums.forEach((num) => console.log((num *= 3)));
3636
};
3737

3838
const logWordsWithExclamation = () => {
39-
//
39+
return words.forEach((word) => console.log(`${word}!`));
4040
};
4141

4242
// Map
4343

4444
const arrayValuesSquaredTimesIndex = () => {
45-
//
45+
return nums.map((num, index) => {
46+
return Math.pow(num, 2) * index;
47+
});
4648
};
4749

4850
const arrayWordsUpcased = () => {
49-
//
51+
return words.map((word) => word.toUpperCase());
5052
};
5153

5254
// Some
5355

5456
const areSomeNumsDivisibleBy7 = () => {
55-
//
57+
return nums.some((num) => num % 7 === 0);
5658
};
5759

5860
const doSomeWordsHaveAnA = () => {
59-
//
61+
return words.some((word) => word.toLowerCase().includes("a"));
6062
};
6163

6264
module.exports = {

0 commit comments

Comments
 (0)