javascript: map and parseInt

by klode

HTML

<div ng-app>
    <div ng-controller="TestCtrl">
        <select ng-model="val" ng-options="v for (k,v) in notes|orderBy:O"></select>
    </div>

JavaScript

function TestCtrl($scope) {

    $scope.notes = {
        '0': 'Non applicable',
        '1': '1 -Très Mauvais',
        '2': '2 -Mauvais',
        '3': '3 -Insuffisant',
            '4': '4 -Mediocre',
            '5': '5 -Moyen',
            '6': '6 -Correct',
            '7': '7 -Bon',
            '8': '8 -Très bon',
            '9': '9 -Excellent',
            '10': '10 -Parfait'
    };
// filter:orderBy(array, expression[, reverse])
   
var t = Object.keys($scope.notes).map(function( num ){ return parseInt( num, 10 ) } )
console.log(t)

var numbers = [1, 4, 9];
var roots = numbers.map(Math.sqrt);
console.log(roots)

}

var orderObject = function (input) {
        if (!angular.isObject(input)) return input;

        var array = [];
        for (var objectKey in input) {
            array.push(input[objectKey]);
        }

        return array;
    }
/*
app.filter('orderObjectBy', function () {
    return function (input, attribute) {
        if (!angular.isObject(input)) return input;

        var array = [];
        for (var objectKey in input) {
            array.push(input[objectKey]);
        }

        array.sort(function (a, b) {
            a = parseInt(a[attribute]);
            b = parseInt(b[attribute]);
            return a - b;
        });
        return array;
    }
});
*/