Write createIdGenerator(prefix): each generator returns unique, increasing ids like user-1, user-2.
Each generator counts on its own, starting at 1. With no prefix, the ids are plain numbers as strings: "1", "2".
function createIdGenerator(prefix = "") {
// your code
}
// const userId = createIdGenerator("user");
// userId(); // "user-1"
// userId(); // "user-2"
// createIdGenerator()(); // "1"
The answer
Write it yourself first. Then compare it with a reference solution and the checks it passes.
Checking your sign-in…