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

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,489 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