Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Making Changes to the DOM DOM Manipulation

Prem Gurusamy
Prem Gurusamy
2,342 Points

I didn't understand , what they're asking here?

I couldn't solve it, please help me

app.js
const contentDiv = document.getElementById("content");
let newParagraph = document.createElement('p');
index.html
<!DOCTYPE html>
<html>
    <head>
        <title>DOM Manipulation</title>
    </head>
    <link rel="stylesheet" href="style.css" />
    <body>
        <div id="content">

        </div>
        <script src="app.js"></script>
    </body>
</html>
Kirkland Harrell
Kirkland Harrell
4,444 Points

Which challenge task couldn't you solve? 1, 2 or 3?

2 Answers

Steven Parker
Steven Parker
231,248 Points

It looks like you're on task 2.

Task 2 says, "Set the class of panel to the newParagraph." Maybe the wording is confusing. What if I restated it this way: "Give the newParagraph you just created a class with the name panel." — would that help?

If you're just not sure how to give an element a class attribute, there are some options. One way is by assigning the className property of the element, and another is to call the classList.add() method.

I'll bet one of those hints will get you going.

Ker Zhang
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Ker Zhang
Full Stack JavaScript Techdegree Graduate 29,113 Points

Yes, the wording of this task is really confusing. I didn't know what to do until I saw Steven's explanation. Thanks!

The answer is simple: newParagraph.className = 'panel';