We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b0e1e9e commit b921fe4Copy full SHA for b921fe4
easy/counter-2.js
@@ -1,3 +1,13 @@
1
+/**
2
+ * Creates a counter object with methods to increment, decrement, and reset the counter.
3
+ *
4
+ * @param {number} init - The initial value of the counter.
5
+ * @returns {object} - An object with three methods:
6
+ * - `increment()`: Increases the counter by 1 and returns the new value.
7
+ * - `reset()`: Resets the counter to the initial value and returns the new value.
8
+ * - `decrement()`: Decreases the counter by 1 and returns the new value.
9
+ */
10
+
11
const createCounter = (init) => {
12
let counter = init;
13
return {
0 commit comments