Generic numeric template formatter

This commit is contained in:
2017-08-17 21:43:41 +02:00
parent 5333ca0870
commit c69f26d1a0

View 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]);
}