This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let sum = arr.reduce((p,c) => p + c, 0); | |
| return `${sum - Math.max(...arr)}, ${sum - Math.min(...arr)}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return sum - Math.max.apply(Math, arr) + ', ' + sum - Math.min.apply(Math, arr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const array = [1, 2, 3]; | |
| function sum(a, b, c) { | |
| return a + b + c; | |
| } | |
| sum(1, 2, 3); // 6 | |
| sum(...array); // = sum(...[1, 2, 3]) = sum(1, 2, 3) -> 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return `${sum - Math.max(...arr)}, ${sum - Math.min(...arr)}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| array.reduce(param1[, param2]); | |
| // param1 - Function(accumulator, currentValue, index, array) | |
| // param2 - accumulator's initial value | |
| // EXAMPLE | |
| [1, 2, 3, 4, 5].reduce((acc, val, i) => { | |
| return acc += val; | |
| }, 0); // 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let sum = arr.reduce((p, c) => p + c, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| regexp.test(param); | |
| // param - String or Function(return String) | |
| //EXAMPLE | |
| /ABC/.test('ABCDEF'); // true | |
| /ABC/.test('ABODEF'); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| array.map(param1[, param2]); | |
| // param1 - Function(value, index, array) | |
| // param2 - Object (to bind as this) | |
| // EXAMPLE | |
| [1, 2, 3, 4, 5].map((val, i, arr) => { | |
| if (arr[i] === val) // always true | |
| return val + i; | |
| }); // [1, 3, 5, 7, 9] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string.split([param1[, param2]]); // All params are optional | |
| // param1 - String or RegExp | |
| // param2 - Number | |
| // EXAMPLE | |
| 'ABCDEF'.split(); // ['ABCDEF'] | |
| 'ABCDEF'.split('CD'); // ['AB', 'EF'] | |
| 'ABCDEF'.split('CD', 1); // ['AB'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string.replace(param1, param2); | |
| // param1 - RegExp or String | |
| // param2 - String or Function(return String) | |
| // EXAMPLE | |
| 'ABC'.replace(/A/, 'X'); // XBC |