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 -

Python Tornado package error when running server -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -