• + 5 comments

    Why do you use abs? I have seen a couple of examples using it and I still can't get it, I have tried using it in javascript but does not work

    function processData(input) {
        var arr = input.split(/[\n]+/);
        var tn = parseInt(arr.shift()), t = 0;
        while (t < tn) {
            var s = arr[t];
            var l = s.length;
            var f = 1;
            for (var i = 1; i < l; i++) {
                if (Math.abs(s[i] - s[i - 1]) == Math.abs(s[l - i] - s[l - i - 1])) {
                    f = f + 1;
                }
            }
    
            console.log(f == l ? 'Funny' : 'Not Funny');
            t++;
        }
    }