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

Stats:

CreatedJul 13, 2021
PublishedJul 13, 2021
Warriors Trained3631
Total Skips76
Total Code Submissions3725
Total Times Completed2054
JavaScript Completions1538
Python Completions432
CoffeeScript Completions14
TypeScript Completions146
Dart Completions11
Total Stars28
% of votes with a positive feedback rating88% of 290
Total "Very Satisfied" Votes234
Total "Somewhat Satisfied" Votes41
Total "Not Satisfied" Votes15
Total Rank Assessments46
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • GabrielReisfeld Avatar
  • JohanWiltink Avatar
  • rowcased Avatar
  • monadius Avatar
Ad