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 trialAlexisca hall
23,683 PointsOn 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>
<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>
3 Answers
Shawn Murray
1,997 PointsSo 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");
Michael Liendo
15,326 PointsI'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
https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
Lean Rasmussen
11,060 PointsAbove 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.
Przemyslaw Chmiel
13,532 Pointslet newParagraph = document.createElement('P');
U should use key createElement
Shaun Wong
14,489 PointsShaun Wong
14,489 PointsThis worked for me, strange it didn't work with let but worked with var