From ec115f0021057ad9307a42660fcab0b4c810ed9d Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 7 Apr 2018 15:57:40 +0300 Subject: [PATCH] Fixed one snippet name not working last.md should now be part of the beginner page --- docs/beginner.html | 8 +++++++- scripts/web.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/beginner.html b/docs/beginner.html index 5aa9a67aa..60d04d2b9 100644 --- a/docs/beginner.html +++ b/docs/beginner.html @@ -23,7 +23,7 @@ - +

logo 30 seconds of code

Curated collection of useful JavaScript snippets
that you can understand in 30 seconds or less.

@@ -134,6 +134,12 @@ Return false if any of them divides the given number, else return < };
isPrime(11); // true
 
+

last

+

Returns the last element in an array.

+

Use arr.length - 1 to compute the index of the last element of the given array and returning it.

+
const last = arr => arr[arr.length - 1];
+
last([1, 2, 3]); // 3
+

lcm

Returns the least common multiple of two or more numbers.

Use the greatest common divisor (GCD) formula and the fact that lcm(x,y) = x * y / gcd(x,y) to determine the least common multiple. diff --git a/scripts/web.js b/scripts/web.js index 83c8f824a..b1daa7c50 100644 --- a/scripts/web.js +++ b/scripts/web.js @@ -51,7 +51,7 @@ const snippetsPath = './snippets', docsPath = './docs'; // Set variables for script let snippets = {}, - beginnerSnippetNames = ['everyNth', 'filterNonUnique', 'last.md', 'maxN', 'minN', 'nthElement', 'sample', 'similarity', 'tail', 'currentURL', 'hasClass', 'getMeridiemSuffixOfInteger', 'factorial', 'fibonacci', 'gcd', 'isDivisible', 'isEven', 'isPrime', 'lcm', 'randomIntegerInRange', 'sum', 'reverseString', 'truncateString'], + beginnerSnippetNames = ['everyNth', 'filterNonUnique', 'last', 'maxN', 'minN', 'nthElement', 'sample', 'similarity', 'tail', 'currentURL', 'hasClass', 'getMeridiemSuffixOfInteger', 'factorial', 'fibonacci', 'gcd', 'isDivisible', 'isEven', 'isPrime', 'lcm', 'randomIntegerInRange', 'sum', 'reverseString', 'truncateString'], startPart = '', endPart = '', output = '',