countNeighbour function rewritten using for loops instead of multiple tests.\n 2 spaces indentation in js is replaced by 4 spaces indentation