Access the first character of each array

Hello,

I am trying to print the first element of each array to the console. Link to problem here https://www.codewars.com/kata/5704aea738428f4d30000914/train/javascript

I feel that I am on the right track here with splitting to make an array, and then make a nested array, but I am having trouble accessing the first character of each array.

function tripleTrouble(one, two, three) {
  const array1 = one.split('');
  const array2 = two.split('');
  const array3 = three.split('');
  let hugeArray = [[array1], 
                   [array2], 
                   [array3]];
  
  console.log(hugeArray[0][0]);
  console.log(hugeArray[1][0]);
  
  
 }

You are wrapping every array in an additional array.

So just remove the extra [ ?

Yep, array1, array2, array3 are already arrays (like your naming correctly suggests :grinning:).

  let hugeArray = [array1, 
                  array2, 
                  array3];

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.