iCharts Problem

by Kyle Falconer

HTML

<div id="console-log"></div>

CSS

.console-line {
    font-family: monospace;
    margin: 2px;
}

JavaScript

var consoleLine = "<p class=\"console-line\"></p>";

console = {
    log: function (text) {
        $("#console-log").append($(consoleLine).html(text));
    }
};

console.log('Hello Kyle');

var sales = {
    'Andrew': 100,
        'Kevin': 200,
        'Eric': 150,
        'Deepak': 250,
        'Bill': '125'
};

Object.prototype.printSorted = function () {
    var temp = [];
    var keys = Object.keys(this);
    for (var o in keys) {
        if (this.hasOwnProperty(keys[o])) {
            temp.push([keys[o], this[keys[o]]]);
        }
    }
    temp.sort(function (a, b) {
        return parseInt(a[1], 10) - parseInt(b[1], 10);
    });
    for (var i = 0; i < temp.length; i++) {
        var k = temp[i][0];
        var v = temp[i][1];
        console.log(k + ' : ' + v);
    }
}

sales.printSorted();