Javascript variable color | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Javascript variable color

I was wondering if I could somehow make a paragraph out of a few variables from the Javascript part so each variable has its own color... Or just one variable has a different color. I combined them with concat() and used toString() for numbers, arrays and similar. I have found fontColor() method, but it doesn’t work... Here’s an example (I’d like to color the number): https://code.sololearn.com/WV88x3mRAewX/?ref=app

31st Jul 2018, 10:30 AM
Val
Val - avatar
4 Answers
+ 2
Your on submit function needs event.preventDefault() to disable form submission to external by default. https://code.sololearn.com/WctSTl1XMSt3/?ref=app
31st Jul 2018, 11:51 AM
Calviղ
Calviղ - avatar
0
There are several errors in your code, but to answer the question you can use .style.color or just CSS to assign the text colour in an element and <span> elements to distinguish between the text.
31st Jul 2018, 11:49 AM
James
James - avatar
0
An example was added
31st Jul 2018, 12:07 PM
Val
Val - avatar
0
You need* to install Juggling-db Master github ¬¬¬¬to be continued
27th Jul 2019, 9:37 AM
Bestender Games
Bestender Games - avatar