hi i am new to angularjs , here i need highest five values in that array instead of only one max value. i had tried but i am getting only one max value.
here is my code.
var arr = [3, 4, 12, 1, 0, 5,22,20,18,30,52];
var max = arr[0];
var maxValues = [];
for (var k = 1; k < arr.length; k++) {
if (arr[k] > max) {
max = arr[k]; // output is 52
//do some thing to push max five values ie 52,30,22,20,18
}
}
console.log("Max is: " + max);
console.log("total five max values is: " + maxValues);expected output[52,30,22,20,18];