Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

On line 2 of app.js, create a paragraph element and assign it to the newParagraph variable.

On line 2 of app.js, create a paragraph element and assign it to the newParagraph variable.

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

        <script src="app.js"></script>

3 Answers

Shawn Murray
Shawn Murray
1,997 Points

So they already provide the declared variable 'newParagraph', and ask us to create a new <p> element. Michael's answer will help with this, but to do it:

var newParagraph = document.createElement("P");

Shaun Wong
Shaun Wong
14,485 Points

This worked for me, strange it didn't work with let but worked with var

Michael Liendo
Michael Liendo
15,326 Points

I'll do you one better ;)

Here's a link to MDN, a site that every JS developer has bookmarked! Specifically, here's the MDN link to the createElement() method


Lean Rasmussen
Lean Rasmussen
11,060 Points

Above is great as always checking documentation is key.

The problem is that you have not specified which kind of element you want to create.

let newParagraph=document.createElement

This lets you make a new element, but you need to say which kind you want.

let newParagraph = document.createElement('P');

U should use key createElement