Find if an array is arithmetic or geometric
I agree with @janos that sometimes returning a string and sometimes returning -1 makes this function hard to use.  In addition, it's unclear what your function is supposed to return for input that is both an arithmetic and a geometric sequence (every element is the same).

I find it odd that you base the difference and ratio on elements at indexes 1 and 2 rather than 0 and 1.  Such an arbitrary choice seems like an unnecessary failure mode for short input arrays.

Note that if the ratio is 0 or infinite, you can immediately declare the sequence to be not geometric.

A better approach is to assume that a sequence is arithmetic or geometric until proven otherwise.

function arithGeo(arr) {
    var diff = arr[1] - arr[0];
    var ratio = arr[1] / arr[0];
    var isArithmetic = true, isGeometric = isFinite(ratio) &amp;&amp; ratio != 0;

    for (var i = 1, j = 2; (isArithmetic || isGeometric) &amp;&amp; j &lt; arr.length; i++, j++) {
        if (isArithmetic &amp;&amp; arr[j] - arr[i] != diff) {
            isArithmetic = false;
        }
        if (isGeometric &amp;&amp; arr[j] / arr[i] != ratio) {
            isGeometric = false;
        }
    }
    return isArithmetic &amp;&amp; isGeometric ? 'both' :
           isArithmetic                ? 'arithmetic' : 
                           isGeometric ? 'geometric'  : '';
}


For clarity, you might as well write it as two independent loops, because the classification problems are independent of each other.  There would be more lines of code, but the complexity of the algorithm remains the same.  Except in degenerate cases, only one of the loops is going to see much action anyway.

function arithGeo(arr) {
    var i, j;

    var diff = arr[1] - arr[0];
    var isArithmetic = true;
    for (i = 1, j = 2; isArithmetic &amp;&amp; j &lt; arr.length; i++, j++) {
        if (isArithmetic &amp;&amp; arr[j] - arr[i] != diff) {
            isArithmetic = false;
        }
    }

    var ratio = arr[1] / arr[0];
    var isGeometric = isFinite(ratio) &amp;&amp; ratio != 0;
    for (i = 1, j = 2; isGeometric &amp;&amp; j &lt; arr.length; i++, j++) {
        if (isGeometric &amp;&amp; arr[j] / arr[i] != ratio) {
            isGeometric = false;
        }
    }

    return isArithmetic &amp;&amp; isGeometric ? 'both' :
           isArithmetic                ? 'arithmetic' : 
                           isGeometric ? 'geometric'  : '';
}