Created
May 13, 2024 05:23
-
-
Save EncodeTheCode/6bef9f24a1c9afce0728780c4e65f2c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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