JSFiddle - React, Tailwind, and code Playground

by nickxbs

JavaScript

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

function createword(chars){
    var k, output = { chars: '' };
    for(k=0; k<chars.length; k++){
        actions.addchar.call(output, chars[k]);
    }
    return output.chars;
}

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