Blog

In JavaScript Find the Max Value in an Array
Posted on June 3, 2015 in Algorithms, JavaScript by Matt Jennings

var x = [1,5,7,10];
var max = x[0];

for(var i = 0; i < x.length; i++) {
    if(x[i] > max) {
        max = x[i];
    }
}
console.log(max);

Leave a Reply