7 kyu
Closure Counter
1,538 of 2,054GabrielReisfeld
Description:
Closure Counter
- Define the function counter that returns a function that returns an increasing value.
- The first value should be 1.
- You're going to have to use closures.
Example:
- const newCounter = counter();
- newCounter() // 1
- newCounter() // 2
Closure:
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
Fundamentals
Similar Kata:
Stats:
Created | Jul 13, 2021 |
Published | Jul 13, 2021 |
Warriors Trained | 3631 |
Total Skips | 76 |
Total Code Submissions | 3725 |
Total Times Completed | 2054 |
JavaScript Completions | 1538 |
Python Completions | 432 |
CoffeeScript Completions | 14 |
TypeScript Completions | 146 |
Dart Completions | 11 |
Total Stars | 28 |
% of votes with a positive feedback rating | 88% of 290 |
Total "Very Satisfied" Votes | 234 |
Total "Somewhat Satisfied" Votes | 41 |
Total "Not Satisfied" Votes | 15 |
Total Rank Assessments | 46 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |