javascript - How to convert array content to uppercase? -


is there non backwards way turn 1 array index uppercase string? don't want split, loop or else, because need 1 string.

colors = [ "red", "green", "blue" ]; red = colors[0]; redupper = red.touppercase(); 

this won't work, because touppercase() string function. know that. i'm looking simplest way achieve this.

if want first element upper case, can use string#touppercase function:

const colors = [ "red", "green", "blue" ];  const redupper = colors[0].touppercase();  console.log(redupper);

if want them all, use array#map.

const colors = [ "red", "green", "blue" ];  console.log(colors.map(a => a.touppercase()));


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -