Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
Add closure task MastersAcademy#1
Browse files Browse the repository at this point in the history
  • Loading branch information
XX-NF-XX committed Nov 28, 2018
1 parent 0fa163e commit 0f89b1b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions homeworks/vitali.timolyanov_XX-NF-XX/homework_5/task_1_closure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function initSummarizer(defaultValue) {
let summ = defaultValue;
return (num) => {
summ += num;
return summ;
};
}

const summarizer = initSummarizer(0);
const testArr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const sumArr = testArr.map(summarizer);

console.log('Test array: ');
console.log(testArr);
console.log('Sum array: ');
console.log(sumArr);

0 comments on commit 0f89b1b

Please sign in to comment.