Get the middle value in three values - Node.js Math

Node.js examples for Math:Compare

Description

Get the middle value in three values

Demo Code

median3: function(a, b, c) {
    if(b <= a)
        if (a <= c)
            return a;
        else if(c <= b)
            return b;
        else/*from   w ww .  j a  v a 2s.c  o  m*/
            return c;
    else if(c <= a)
        return a;
    else if(c <= b)
        return c;
    else
        return b;
},

Related Tutorials