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

26th May 2025, 5:58 PM
Lumi✨
Lumi✨ - avatar
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
27th May 2025, 12:49 AM
Bob_Li
Bob_Li - avatar
+ 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
27th May 2025, 1:07 AM
Bob_Li
Bob_Li - avatar
+ 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";     
27th May 2025, 1:02 AM
Chris Coder
Chris Coder - avatar
+ 2
Whats the problem?
26th May 2025, 6:22 PM
Zvi
Zvi - avatar
+ 1
Your code is working fine
26th May 2025, 6:14 PM
Manav Roy
Manav Roy - avatar
+ 1
Lumi✨ Bob_Li solved it. You have to import the font , please view his code example
27th May 2025, 12:54 PM
Chris Coder
Chris Coder - avatar
0
Zvi Manav Roy No I want the paragraph to change into font family handel when I click the button but it is not working.
27th May 2025, 12:39 PM
Lumi✨
Lumi✨ - avatar
0
Chris Coder okay thx
27th May 2025, 12:55 PM
Lumi✨
Lumi✨ - avatar
0
Hello
28th May 2025, 5:48 PM
علی
علی - avatar
OSZAR »