var file = '4\n1 2 3 2 3 4 5 1 4 6'; var rows = file.split('\n'); var height = rows[0]; var depths = rows[1].split(' '); console.log(height, depths);