How to create a string from one row of a two-dimensional character array in Node.js

1 Answer

0 votes
// Create and initialize the 2D array
const charArray2D = [
    ['N', 'o', 'd', 'e', '.', 'j', 's'],
    ['J', 'a', 'v', 'a', 'S', 'c', 'r', 'i', 'p', 't'],
    ['r', 'u', 'n', 't', 'i', 'm', 'e']
];

// row 0 (first row)
const rowIndex = 0;
const selectedRow = charArray2D[rowIndex];

// Convert the row to a string
const s = selectedRow.join('');

console.log(s);


/*
run:

Node.js

*/

 



answered Feb 7, 2025 by avibootz
...