Exercise - Data Grid (Basic)

by Satish Kesiboyana

JavaScript

/**
 * Grid Builder
 * Create a function "gridify" that accepts an array of similar objects
 * It will output a "table" in the console
 * The header row will be the property names and should display ONCE
 * The body rows will be the property values
 *
 * Hint: use tabs to align, "/t" is the tab character. 
 * Don't worry about strings that are too long and break into the next tab column
 *
 */

/* your code here */

var gridify ([
    {name: "Ryan", value: 913},
    {name: "Jimmy", value: 20003},
    {name: "Donna", value: 923}    
]);

var lo = (function grid_layout(arr) {
    var tk = Object.keys(arr);
    for (var i=0; i< tk; i++) {
        
        if (i==0) {
            console.log(tk[i]);    
        }
        else {
            arr[i][propName];
        }
    }
    
}(gridify));

/*
ex output:
Name      Value
Ryan      913
Jimmy     20003
Donna     923
*/