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 Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Modifying Elements

Not Sure what to do

I am not sure what to do with this challange

app.js
var body = document.body;
var newParagraph = document.createElement("p");
var pleaseEnableParagraph = document.querySelector("#please_enable");

// Add text to the new paragraph



//Remove "Please Enable JavaScript" paragraph

body.removeChild(pleaseEnableParagraph);

//Append new paragaph to document

body.appendChild(newParagraph);
index.html
<!DOCTYPE html>
<html>
  <body>
    <p id="please_enable">Please Enable JavaScript</p>

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

2 Answers

Hey Andrew,

This challenge wants you to add text to the new paragraph that is created. The way you can do that to text based elements such as paragraphs, divs, sections, spans, etc. is to modify either their textContent/innerText or innerHTML property. Using those text properties allows you to add/replace any text data within the element. Using the innerHTML property can allow you to add text and/or elements to another element. The text properties are faster to use than the HTML property. So, any of those properties are valid ways to set the text in the element.

newParagraph.textContent = "JavaScript is enabled";
//or:
//newParagraph.innerText = "JavaScript is enabled";
//or:
//newParagraph.innerHTML = "JavaScript is enabled";

I am no javascript expert, but from the looks of the question it looks like it wants you to tie a paragraph to a document using javascript.

Sorry i could not be of more help.