JavaScript solution for diagonal difference
You don't need the inner for loops because you know exactly which array element you want for each sum:

for(currentLine = 1 ; currentLine &lt;= numberOfInputs ; currentLine++)
    {
        var inputs = inputAll[currentLine];
        var inputArray = inputs.split(" ");

        sumFirstDiagonal += parseInt( inputArray[ currentLine - 1 ])
        sumSecondDiagonal += parseInt (inputArray [ inputArray.length - currentLine ])

    }