Generic numeric template formatter
This commit is contained in:
8
generic-numeric-template-formatter/index.js
Normal file
8
generic-numeric-template-formatter/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generic numeric template formatter
|
||||
// https://www.codewars.com/kata//train/javascript
|
||||
|
||||
function numericFormatter(template, digits) {
|
||||
digits = digits || '1234567890';
|
||||
let cnt = 0;
|
||||
return template.replace(/[a-z]/gi, c => digits[cnt++ % digits.length]);
|
||||
}
|
||||
Reference in New Issue
Block a user