Skip to content

Commit b5adfce

Browse files
committed
feat(pascal): better names for variables
1 parent c629198 commit b5adfce

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

19_pascal/solution/pascal-solution.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ const pascal = function (counter, currentLine = [1]) {
44
}
55

66
const halfOfNextLine = currentLine.reduce(
7-
(accumulator, currentElement, index, originalArray) => {
8-
const nextElement = originalArray[index + 1]
9-
if (currentElement <= nextElement) {
10-
return [...accumulator, currentElement + nextElement];
7+
(numbers, currentNumber, index) => {
8+
const nextNumber = currentLine[index + 1];
9+
if (currentNumber <= nextNumber) {
10+
return [...numbers, currentNumber + nextNumber];
1111
}
12-
return accumulator;
12+
return numbers;
1313
},
1414
[1],
1515
);
1616

17-
// Notice that pascal triangle's lines are always palindromic in nature.
17+
// Notice that pascal triangle's lines are always palindromic in nature.
1818
// We only need the first half to obtain the information to construct the second half
1919
const joined = [...halfOfNextLine, ...halfOfNextLine.reverse()];
2020

0 commit comments

Comments
 (0)