From 833f742ffeabbe1e70d9b2c9a96e16f20aa082b6 Mon Sep 17 00:00:00 2001 From: bobby569 Date: Fri, 29 Dec 2017 22:41:43 -0500 Subject: [PATCH] fix fibonacci example typo --- README.md | 7 +++---- docs/index.html | 4 ++-- snippets/fibonacci.md | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 112aa68c6..eaefaf6ee 100644 --- a/README.md +++ b/README.md @@ -1107,8 +1107,8 @@ console.log(pulled); // [ 'b', 'd' ] QuickSort an Array (ascending sort by default). -Use recursion. -Use `Array.filter` and spread operator (`...`) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it. +Use recursion. +Use `Array.filter` and spread operator (`...`) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it. If the parameter `desc` is truthy, return array sorts in descending order. ```js @@ -2276,7 +2276,7 @@ const factorial = n => Examples ```js -factorial(6); // 720 +factorial(6); // [0, 1, 1, 2, 3, 5] ``` @@ -4138,4 +4138,3 @@ validateNumber('10'); // true ## Credits *Icons made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [www.flaticon.com](https://www.flaticon.com/) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/).* - diff --git a/docs/index.html b/docs/index.html index a45295e6e..57d3b801a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -436,7 +436,7 @@ collatz(5); // 16 (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), [] ); -
fibonacci(6); // 720
+
fibonacci(6); // [0, 1, 1, 2, 3, 5]
 

fibonacciCountUntilNum

Returns the number of fibonnacci numbers up to num(0 and num inclusive).

Use a mathematical formula to calculate the number of fibonacci numbers until num.

const fibonacciCountUntilNum = num =>
   Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
 
fibonacciCountUntilNum(10); // 7
@@ -842,4 +842,4 @@ console.log(sdbm('age')); // 808122783
 
toOrdinalSuffix('123'); // "123rd"
 

validateNumber

Returns true if the given value is a number, false otherwise.

Use !isNaN in combination with parseFloat() to check if the argument is a number. Use isFinite() to check if the number is finite. Use Number() to check if the coercion holds.

const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
 
validateNumber('10'); // true
-

\ No newline at end of file +
diff --git a/snippets/fibonacci.md b/snippets/fibonacci.md index 0f14bce2b..382886e66 100644 --- a/snippets/fibonacci.md +++ b/snippets/fibonacci.md @@ -14,5 +14,5 @@ const fibonacci = n => ``` ```js -fibonacci(6); // 720 +fibonacci(6); // [0, 1, 1, 2, 3, 5] ```