Loop through input fields with jQuery to find the highest value?

jquery

Solution

Here is one solution:

var highest = -Infinity;
$("input[type='text']").each(function() {
    highest = Math.max(highest, parseFloat(this.value));
});
console.log(highest);

Here is another solution:

var highest = $("input[type='text']").map(function() {
    return parseFloat(this.value);
}).get().sort().pop();

console.log(highest);

Problem

I have a number of `input[type=text]` fields on my page and I want to loop through all of them in order to find and return the highest value. Is there a way to do this with jQuery? Thanks for any help.

Original source