From 81e37d20c0b09382bdc4aa06ca3daa85fde61f3c Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Tue, 3 Nov 2020 21:46:13 +0200 Subject: [PATCH] Consistent whitespace --- snippets/CSVToArray.md | 6 +++--- snippets/RGBToHex.md | 2 +- snippets/accumulate.md | 2 +- snippets/chunkIntoN.md | 2 +- snippets/initial.md | 2 +- snippets/lcm.md | 2 +- snippets/luhnCheck.md | 2 +- snippets/partition.md | 5 ++++- snippets/removeWhitespace.md | 2 +- snippets/weightedAverage.md | 2 +- snippets/zipWith.md | 2 +- 11 files changed, 16 insertions(+), 13 deletions(-) diff --git a/snippets/CSVToArray.md b/snippets/CSVToArray.md index 0af1283df..8f5c15f5a 100644 --- a/snippets/CSVToArray.md +++ b/snippets/CSVToArray.md @@ -19,7 +19,7 @@ const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => ``` ```js -CSVToArray('a,b\nc,d'); // [['a','b'],['c','d']]; -CSVToArray('a;b\nc;d', ';'); // [['a','b'],['c','d']]; -CSVToArray('col1,col2\na,b\nc,d', ',', true); // [['a','b'],['c','d']]; +CSVToArray('a,b\nc,d'); // [['a', 'b'], ['c', 'd']]; +CSVToArray('a;b\nc;d', ';'); // [['a', 'b'], ['c', 'd']]; +CSVToArray('col1,col2\na,b\nc,d', ',', true); // [['a', 'b'], ['c', 'd']]; ``` diff --git a/snippets/RGBToHex.md b/snippets/RGBToHex.md index 2cb68f207..91a21823f 100644 --- a/snippets/RGBToHex.md +++ b/snippets/RGBToHex.md @@ -6,7 +6,7 @@ tags: string,math,intermediate Converts the values of RGB components to a hexadecimal color code. - Convert given RGB parameters to hexadecimal string using bitwise left-shift operator (`<<`) and `Number.prototype.toString(16)`. -- Use `String.prototype.padStart(6,'0')` to get a 6-digit hexadecimal value. +- Use `String.prototype.padStart(6, '0')` to get a 6-digit hexadecimal value. ```js const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); diff --git a/snippets/accumulate.md b/snippets/accumulate.md index ae8683905..707195949 100644 --- a/snippets/accumulate.md +++ b/snippets/accumulate.md @@ -10,7 +10,7 @@ Creates an array of partial sums. ```js const accumulate = (...nums) => - nums.reduce((acc, n) => [...acc, n + +acc.slice(-1)],[]); + nums.reduce((acc, n) => [...acc, n + +acc.slice(-1)], []); ``` ```js diff --git a/snippets/chunkIntoN.md b/snippets/chunkIntoN.md index 946754c13..3fa087486 100644 --- a/snippets/chunkIntoN.md +++ b/snippets/chunkIntoN.md @@ -20,5 +20,5 @@ const chunkIntoN = (arr, n) => { ``` ```js -chunkIntoN([1, 2, 3, 4, 5, 6, 7], 4); // [[1,2], [3,4], [5,6], [7]] +chunkIntoN([1, 2, 3, 4, 5, 6, 7], 4); // [[1, 2], [3, 4], [5, 6], [7]] ``` diff --git a/snippets/initial.md b/snippets/initial.md index f297f100a..0b0e9f03c 100644 --- a/snippets/initial.md +++ b/snippets/initial.md @@ -5,7 +5,7 @@ tags: array,beginner Returns all the elements of an array except the last one. -- Use `Array.prototype.slice(0,-1)` to return all but the last element of the array. +- Use `Array.prototype.slice(0, -1)` to return all but the last element of the array. ```js const initial = arr => arr.slice(0, -1); diff --git a/snippets/lcm.md b/snippets/lcm.md index 328d5c72b..2e63fbe1b 100644 --- a/snippets/lcm.md +++ b/snippets/lcm.md @@ -5,7 +5,7 @@ tags: math,recursion,intermediate Calculates 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. +- 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. - The GCD formula uses recursion. ```js diff --git a/snippets/luhnCheck.md b/snippets/luhnCheck.md index 5090212e4..a86e7f46c 100644 --- a/snippets/luhnCheck.md +++ b/snippets/luhnCheck.md @@ -6,7 +6,7 @@ tags: math,advanced Implementation of the [Luhn Algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers etc. - Use `String.prototype.split('')`, `Array.prototype.reverse()` and `Array.prototype.map()` in combination with `parseInt()` to obtain an array of digits. -- Use `Array.prototype.splice(0,1)` to obtain the last digit. +- Use `Array.prototype.splice(0, 1)` to obtain the last digit. - Use `Array.prototype.reduce()` to implement the Luhn Algorithm. - Return `true` if `sum` is divisible by `10`, `false` otherwise. diff --git a/snippets/partition.md b/snippets/partition.md index 26a9c21e5..feef49186 100644 --- a/snippets/partition.md +++ b/snippets/partition.md @@ -25,5 +25,8 @@ const users = [ { user: 'fred', age: 40, active: true }, ]; partition(users, o => o.active); -// [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]] +// [ +// [{ user: 'fred', age: 40, active: true }], +// [{ user: 'barney', age: 36, active: false }] +// ] ``` diff --git a/snippets/removeWhitespace.md b/snippets/removeWhitespace.md index 12aab3411..17e2090a0 100644 --- a/snippets/removeWhitespace.md +++ b/snippets/removeWhitespace.md @@ -8,7 +8,7 @@ Returns a string with whitespaces removed. - Use `String.prototype.replace()` with a regular expression to replace all occurrences of whitespace characters with an empty string. ```js -const removeWhitespace = str => str.replace(/\s+/g,''); +const removeWhitespace = str => str.replace(/\s+/g, ''); ``` ```js diff --git a/snippets/weightedAverage.md b/snippets/weightedAverage.md index 9b79e6bd3..1a5e1c22d 100644 --- a/snippets/weightedAverage.md +++ b/snippets/weightedAverage.md @@ -23,5 +23,5 @@ const weightedAverage = (nums, weights) => { ``` ```js -weightedAverage([1, 2, 3], [0.6,0.2,0.3]); // 1.72727 +weightedAverage([1, 2, 3], [0.6, 0.2, 0.3]); // 1.72727 ``` diff --git a/snippets/zipWith.md b/snippets/zipWith.md index 16968467e..a93168dc6 100644 --- a/snippets/zipWith.md +++ b/snippets/zipWith.md @@ -22,7 +22,7 @@ const zipWith = (...array) => { ``` ```js -zipWith([1, 2], [10, 20], [100, 200], (a, b, c) => a + b + c); // [111,222] +zipWith([1, 2], [10, 20], [100, 200], (a, b, c) => a + b + c); // [111, 222] zipWith( [1, 2, 3], [10, 20],