Skip to content

Instantly share code, notes, and snippets.

@EncodeTheCode
Created May 13, 2024 05:23
Show Gist options
  • Save EncodeTheCode/6bef9f24a1c9afce0728780c4e65f2c6 to your computer and use it in GitHub Desktop.
Save EncodeTheCode/6bef9f24a1c9afce0728780c4e65f2c6 to your computer and use it in GitHub Desktop.
class DataIdGenerator {
constructor() {
this.count = 0;
}
generateDataId() {
this.count++;
return this.formatDataId(this.count);
}
formatDataId(number) {
return String(number).padStart(2, '0');
}
}
// Test the generator
const generator = new DataIdGenerator();
for (let i = 0; i < 15; i++) {
console.log(generator.generateDataId());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment