+ 2

Need help - color string array

Can I color a string array color element (example var myColors = ["red", "blue"]) to show up in that color in Code Playground using JavaScript and CSS? I've looked this up and can't find anything so far. Also it has to be in a textbox... So, I want myColors red to be displayed as a red color; red in red, blue in blue UPDATE var csColors = ["brown", "red", "orange", "yellow", "green", "blue", "violet", "teal"]; So, what I want is for them to show up as their related colors. when it randomly picks a color, I want the user to see it in that same color. I have a light brown background and want the colors to simulate paint on a pallet... I don't think CSS can interact with arrays or functions, as far as I know... This isn't important for the program to run, I just thought it would be cool to see.

8th May 2018, 1:36 PM
James Pinkerton
James Pinkerton - avatar
1 Réponse
+ 3
I'm not understanding you really well here, do you want to have several text input to have different color/background color using the colors saved in the array? elaborate more about it plz...
11th May 2018, 11:03 AM
Ipang