JSFiddle - React, Tailwind, and code Playground

by Tom Randolph

HTML

<div id="output"></div>

JavaScript

var output = document.getElementById( "output" ),
    span, br, fspan, fbr;

function test(){
    var test = [
        { 'count' : 1 , 'average' : 2 , 'total' : 3 } ,
        { 'count' : 10 , 'average' : 20 , 'total' : 30 } , 
        { 'count' : 100 , 'average' : 200 , 'total' : 300 }
    ];
    
    fspan = document.createElement( "span" );
    fbr = document.createElement( "br" );
    
    fspan.textContent = "Init State: " + test[0].count + ", " + test[1].count + ", " + test[2].count;
    
    output.appendChild( fspan );
    output.appendChild( fbr );

    test.forEach( function( element , service_index , array ){
        span = document.createElement( "span" );
        br = document.createElement( "br" );
        array[ service_index ].count = 1111111 ;
        array[ service_index ].average = 2222222 ;
        array[ service_index ].total = 3333333 ;
        
        span.textContent = "Object Index: " + service_index + ", count: " + array [ service_index ].count;
        
        output.appendChild( span );
        output.appendChild( br );
    });
}

test();