diff --git a/README.md b/README.md index 220194568..4c0b3e1f0 100644 --- a/README.md +++ b/README.md @@ -4740,6 +4740,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]); + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true @@ -5616,8 +5617,8 @@ Throws an exception if `n` is a negative number. 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); @@ -7032,9 +7033,9 @@ 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); ```
diff --git a/docs/function.html b/docs/function.html index 2b9ef5087..b7dd9ee2e 100644 --- a/docs/function.html +++ b/docs/function.html @@ -156,6 +156,7 @@ console.log< + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true diff --git a/docs/math.html b/docs/math.html index 7f4cf8cd2..523585d93 100644 --- a/docs/math.html +++ b/docs/math.html @@ -152,8 +152,8 @@ own individual rating by supplying it as the third argument.

factorial

Calculates the factorial of a number.

Use recursion. If n is less than or equal to 1, return 1. Otherwise, return the product of n and the factorial of n - 1. Throws an exception if n is a negative number.

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);
diff --git a/docs/object.html b/docs/object.html
index 9e407de65..7d6985385 100644
--- a/docs/object.html
+++ b/docs/object.html
@@ -190,9 +190,9 @@ o[1in 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);
 
const data = {
   level1: {
     level2: {
diff --git a/snippets/checkProp.md b/snippets/checkProp.md
index 3262f3969..627fa7cb8 100644
--- a/snippets/checkProp.md
+++ b/snippets/checkProp.md
@@ -21,6 +21,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
 
 
 
+
 const lengthIs4 = checkProp(l => l === 4, 'length');
 lengthIs4([]); // false
 lengthIs4([1,2,3,4]); // true
diff --git a/snippets/dig.md b/snippets/dig.md
index 737130b6e..c97559833 100644
--- a/snippets/dig.md
+++ b/snippets/dig.md
@@ -10,9 +10,9 @@ 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
diff --git a/snippets/factorial.md b/snippets/factorial.md
index cf3acc9cc..86ebe69b6 100644
--- a/snippets/factorial.md
+++ b/snippets/factorial.md
@@ -11,8 +11,8 @@ Throws an exception if `n` is a negative number.
 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);
diff --git a/test/_30s.js b/test/_30s.js
index 2c0a2ba21..3f93b3e52 100644
--- a/test/_30s.js
+++ b/test/_30s.js
@@ -272,9 +272,9 @@ 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);
 const digitize = n => [...`${n}`].map(i => parseInt(i));
 const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
 const drop = (arr, n = 1) => arr.slice(n);
@@ -347,8 +347,8 @@ const extendHex = shortHex =>
 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);