Is it allowed to do something like Array[i - 1] in javascript? Assuming that i and i-1 are proper indexes of the Array.
I am wondering because it seems to give me errors but I don't know if the error is how I refer to indexes.
Furthermore, is it possible to do something like Array[Array.length - 1]?
The actual error is with this:
input = input.split('\n');
for (var i = 1; i < input.length; i++){
for (var j = 0; j < input[i].length; j++){
process.stdout.write(input[i][j]);
process.stdout.write(input[i][j - 1]);
process.stdout.write(input[i][input[i].length - 1 - j]);
process.stdout.write(input[i][input[i].length - j]);
if (input[i][j] - input[i][j - 1] !== input[i][input[i].length - 1 - j] - input[i][input[i].length - j]){
}
}
}
Of the process.stdout.write statements, only the first outputs anything.
[ ]so long as it evaluates to a number or a string. Post your actual code and the actual errors you're getting.[].a.length - 1as index to the array, in fact it is used to get the last element from array