Travis build: 1012

This commit is contained in:
30secondsofcode
2019-02-23 10:50:43 +00:00
parent 9c607d00f2
commit 240e38b4a0
23 changed files with 3504 additions and 3512 deletions

5859
README.md

File diff suppressed because it is too large Load Diff

View File

@ -339,6 +339,7 @@
<li><a tags="math,beginner,intermediate" href="./math#isprime">isPrime</a></li>
<li><a tags="math,recursion,beginner" href="./math#lcm">lcm</a></li>
<li><a tags="math,utility,advanced" href="./math#luhncheck">luhnCheck</a></li>
<li><a tags="math,beginner" href="./math#mapnumrange">mapNumRange</a></li>
<li><a tags="math,array,function,beginner" href="./math#maxby">maxBy</a></li>
<li><a tags="math,array,intermediate" href="./math#median">median</a></li>
<li><a tags="math,array,beginner" href="./math#midpoint">midpoint</a></li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -339,6 +339,7 @@
<li><a tags="math,beginner,intermediate" href="./math#isprime">isPrime</a></li>
<li><a tags="math,recursion,beginner" href="./math#lcm">lcm</a></li>
<li><a tags="math,utility,advanced" href="./math#luhncheck">luhnCheck</a></li>
<li><a tags="math,beginner" href="./math#mapnumrange">mapNumRange</a></li>
<li><a tags="math,array,function,beginner" href="./math#maxby">maxBy</a></li>
<li><a tags="math,array,intermediate" href="./math#median">median</a></li>
<li><a tags="math,array,beginner" href="./math#midpoint">midpoint</a></li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,17 +8,16 @@ Use `Object.keys(obj)` to iterate over the object's keys.
Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.
```js
const deepMapKeys = (obj, f) =>
Array.isArray(obj)
? obj.map(val => deepMapKeys(val, f))
: typeof obj === 'object'
? Object.keys(obj).reduce((acc, current) => {
const val = obj[current];
acc[f(current)] =
const val = obj[current];
acc[f(current)] =
val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);
return acc;
}, {})
return acc;
}, {})
: obj;
```

View File

@ -6,14 +6,13 @@ Use the `in` operator to check if `target` exists in `obj`.
If found, return the value of `obj[target]`, otherwise use `Object.values(obj)` and `Array.prototype.reduce()` to recursively call `dig` on each nested object until the first matching key/value pair is found.
```js
const dig = (obj, target) =>
target in obj
? obj[target]
: Object.values(obj).reduce((acc, val) => {
if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target);
}, undefined);
if (acc !== undefined) return acc;
if (typeof val === 'object') return dig(val, target);
}, undefined);
```
```js

View File

@ -8,12 +8,11 @@ Otherwise, return the product of `n` and the factorial of `n - 1`.
Throws an exception if `n` is a negative number.
```js
const factorial = n =>
n < 0
? (() => {
throw new TypeError('Negative numbers are not allowed!');
})()
throw new TypeError('Negative numbers are not allowed!');
})()
: n <= 1
? 1
: n * factorial(n - 1);

View File

@ -5,9 +5,11 @@ Maps a number from one range to another range.
Returns `num` mapped between `outMin`-`outMax` from `inMin`-`inMax`.
```js
const mapNumRange = (num, inMin, inMax, outMin, outMax) => (num - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
```
```js
mapNumRange(5,0,10,0,100); // 50
mapNumRange(5, 0, 10, 0, 100); // 50
```

View File

@ -11,14 +11,13 @@ const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Pr
```
```js
const sum = pipeAsyncFunctions(
x => x + 1,
x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),
x => x + 3,
async x => (await x) + 4
);
(async() => {
(async () => {
console.log(await sum(5)); // 15 (after one second)
})();
```

View File

@ -6,13 +6,12 @@ Use `Array.prototype.filter()` to find array elements that return truthy values
The `func` is invoked with three arguments (`value, index, array`).
```js
const remove = (arr, func) =>
Array.isArray(arr)
? arr.filter(func).reduce((acc, val) => {
arr.splice(arr.indexOf(val), 1);
return acc.concat(val);
}, [])
arr.splice(arr.indexOf(val), 1);
return acc.concat(val);
}, [])
: [];
```

File diff suppressed because it is too large Load Diff