const availableTags = ['div', 'h1', 'p', 'span']; function tagsCollector() { this.tags = []; this.addTag = function(tag) { this.tags.push(tag); } } class Format { constructor() { this.tags = new tagsCollector(); } } availableTags.forEach(tag => { Object.defineProperty(Format.prototype, tag, { value: new Proxy(text => { return ` <${tag}> <${this.tags.reduceRight((html, curtag) => { return `<${curtag}>${html}</${curtag}>`; }, text)} </${tag}> ` }, { get: (_, props) => { this.tags.addTag(tag); return this; }}) }) })El desafío es el formato HTML relacionado con el campo de codewars. Necesitamos implementar el patrón de interfaz fluida del tipo Format.div.p ('texto'). Para cada etiqueta, creo un getter que toma la etiqueta de la etiqueta en tagCollector y devuelve el objeto Format actual. Pensé en enviarle un proxy al captador, pero luego se perdió la llamada y no puedo acceder a this.tags.