Set the paragraph colour to red and report it back.
Acceptance criteria
- 1.#out should show red.
JavaScript Tutorial · JavaScript DOM
These 10 tasks go with the JavaScript DOM Styles chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “The style property changes an element's appearance directly from JavaScript.” .
1.Set a colourexercise · easy · 10 min
Set the paragraph colour to red and report it back.
Passes when: #out should show red.
2.Use a camel case nameexercise · easy · 10 min · practice plan
Set the background colour and report the value back.
Passes when: #out should show yellow.
3.Include the unitexercise · easy · 10 min · practice plan
Set the width to 200 pixels and report the value.
Passes when: #out should show 200px.
4.Read a computed styleexercise · easy · 10 min · practice plan
Report the colour the browser actually applied.
Passes when: #out should show rgb(0, 0, 255).
5.Set several stylesexercise · medium · 10 min · practice plan
Set the font size and padding, then report the font size.
Passes when: #out should show 20px.
6.Fix the dashed property namebug fix · easy · 8 min
A dashed CSS name is not valid in JavaScript.
Passes when: #out should show yellow.
7.Fix the missing unitbug fix · easy · 8 min · practice plan
A width without a unit is ignored.
Passes when: #out should show 200px.
8.Fix style used to read a stylesheet valuebug fix · easy · 8 min · practice plan
The style property only sees inline styles.
Passes when: #out should show the computed colour.
9.Fix the style set on a collectionbug fix · easy · 8 min · practice plan
querySelectorAll returns a list, which has no style property.
Passes when: #out should show red.
10.Fix the value written without quotesbug fix · easy · 8 min · practice plan
A style value must be a string.
Passes when: #out should show 20px.
Between them these tasks cover style property, Camel case and getComputedStyle.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.