JSFiddle - React, Tailwind, and code Playground

JavaScript

var actions = {
    addchar: function(char){
    console.log(this, char)
        this.chars = this.chars + char;
    }
}

function createword(chars){
    var k, output = { chars: '' };
    for(k=0; k<chars.length; k++){
        /* utilizzare addchar per far passare il test */
        actions.addchar.call(output, chars[k]);
    }
    return output.chars;
}

console.log('t1', createword(['h','e','l','l','o']) === "hello");