I am trying to retrieve the first, and proceeding letters in an array of strings. What I have been working on is looping over each item and then printing arr[i][0], but this does not work for the proceeding letters.
For example:
Input:
'
00100
11110
10110
Output:
011010111011000
Basically, I want to traverse vertically, not horizontally.
function solution(s) {
// transform string into array
let arr = s.split('\n')
for (let i = 0; i < arr.length; i++) {
// log the first, then proceeding letter in each string
console.log(arr[i][0])
}
}
console.log(
solution(`00100
11110
10110
`)
)