Syntax for referring to the second character of the first item in an array

let myArray = [“simon”, “fred”];
console.log(myArray[0])

this will output simon
but I want to output ‘m’ (not the whole name).
what is the syntax?
Thanks

Hi @fuell.python !

I would suggest looking into the split method

Hope that helps

Hi :slight_smile:
I am sure that would do it but is there not something like
let myArray = [“simon”, “fred”]

console.log(myArray[0,0]
// 0 refers to 1st item and next zero to the first letter.
I know this doesn’t work but surely its just a comma or something??
Thanks again very much

console.log(myArray[0][2])

LOL.

My face goes a little red.
Thanks

I tried everything but the obvious .
Have a lovely day.
Simon

1 Like

It’s ok.

My first suggestion added extra steps that weren’t really necessary :laughing:
But know you now about the split method :grinning:

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