+ 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
14 Respostas
+ 4
But it still isn't changing the color of the text?
+ 4
Thank you
+ 4
I've learned it on the Js lessons but I don't really understand it
+ 4
Yet😉
+ 4
Um.. No I don't think so
+ 3
document.getElementById("demo").style = style;
https://code.sololearn.com/WL3scoS39hKs/?ref=app
+ 2
https://code.sololearn.com/Wg4KvM0F6m0b/?ref=app
+ 1
Avoid variable same name as keyword
Declare variable.
var style1;
_DOM_.style = style1;
Try the same code above.
+ 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.
+ 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?
+ 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)
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.