0
Can anyone help me debug this
Can anyone help me debug this? I just can't find the error. https://sololearn.com/compiler-playground/Wh8Go41z0HWA/?ref=app
9 Respostas
+ 6
to use a non standard font, you have to import it.
it's also more flexible to use classes rather than modifying the style directly
https://sololearn.com/compiler-playground/WEiPKWwN7MwR/?ref=app
+ 4
Chris Coder , you're right. we all have to start from simpler concepts, and I really should have commented the code properly. also my preference for short codes often have me typing out ternary expressions all the time... 😅
as for learning what classes are, that's what Sololearn html/css courses are for.
but it's basically style groupings that can be applied to html elements. the OP was applying javascript so I assumed that css was already understood.
the ternary expression:
btn.textContent = btn.textContent=="Click to style" ? "Remove style" : "Click to style";
is a shorthand for:
if(btn.textContent=="Click to style) {
btn.textContent = "Remove style";
} else {
btn.textContent = "Click to style";
}
so that the button text will change when the button is clicked.
ok here's a more basic version with no class toggling. it's more verbose, but it basically does the same thing.
https://sololearn.com/compiler-playground/WOkf4YSfa76o/?ref=app
+ 3
Bob_LiAssuming I'm new to coding.
What are classes?
How does this line work?
btn.textContent = btn.textContent=="Click to style" ? "Remove style" : "Click to style";
+ 2
Whats the problem?
+ 1
Your code is working fine
0
Chris Coder okay thx
0
Hello