+ 4

What did I do wrong? I'm trying to make it where each day has its own color

I'm trying to make each day have a different color https://code.sololearn.com/W0LnfV3Iuzlo/?ref=app

2nd Dec 2018, 2:53 AM
Abraham
Abraham - avatar
14 Respostas
2nd Dec 2018, 5:23 AM
Abraham
Abraham - avatar
+ 4
But it still isn't changing the color of the text?
2nd Dec 2018, 2:59 AM
Abraham
Abraham - avatar
+ 4
Thank you
2nd Dec 2018, 3:03 AM
Abraham
Abraham - avatar
+ 4
I've learned it on the Js lessons but I don't really understand it
2nd Dec 2018, 5:11 AM
Abraham
Abraham - avatar
+ 4
Yet😉
2nd Dec 2018, 5:11 AM
Abraham
Abraham - avatar
+ 4
Um.. No I don't think so
2nd Dec 2018, 5:16 AM
Abraham
Abraham - avatar
+ 3
document.getElementById("demo").style = style; https://code.sololearn.com/WL3scoS39hKs/?ref=app
2nd Dec 2018, 2:55 AM
Gordon
Gordon - avatar
+ 2
https://code.sololearn.com/Wg4KvM0F6m0b/?ref=app
2nd Dec 2018, 3:48 AM
Calviղ
Calviղ - avatar
+ 1
Avoid variable same name as keyword Declare variable. var style1; _DOM_.style = style1; Try the same code above.
2nd Dec 2018, 3:02 AM
Gordon
Gordon - avatar
+ 1
For document.getElementById("demo").style = style; I think the code should not be used, It would hijack all the CSS styles you have previously set. If you want to change the text color of #demo, you can set document.getElementById("demo").style.color = style; // where style = "blue", for example.
2nd Dec 2018, 4:32 AM
Calviղ
Calviղ - avatar
+ 1
Come to think of it, the most common way is using array as switch because of the numeric nature of the returned value of getDay(). Have you learned array yet, Abraham?
2nd Dec 2018, 4:55 AM
Gordon
Gordon - avatar
+ 1
//You define an array in this way: var array1 = ["Apple", "Banana", "Orange"]; //And then you can access using index, first one is 0. console.log( array1[0]) //Output Apple console.log( array1[1]) //Ouput Banana console.log( array1[2]) //Output Orange Now, do you have clue how to improve your code? (in terms of making it shorter and simpler)
2nd Dec 2018, 5:15 AM
Gordon
Gordon - avatar
0
Can you try to copy my above answer into a blank web code in code playground, and then run it to see the output first? And post the link of your new code here, I'll go into that code to tell you what's next to know.
2nd Dec 2018, 5:18 AM
Gordon
Gordon - avatar