JSFiddle - React, Tailwind, and code Playground

by akoptsov

HTML

<div class='text'></div>

CSS

.text{
    font-size: large;
    color: gray;
}

JavaScript

String.prototype.format = function () {
    var args = arguments;
    return this.replace(/{(\d+)}/g, function (match, i) { 
        $('body').append('<div> { match: '+match+', i:'+i+'}</div>');
        return i < args.length ? args[i] : ('{' + (i - args.length) + '}'); 
    });
};

$('.text').html('The {2} {1} fox jumps over the {0} dog'.format('lazy', 'brown', 'quick'));