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

Code Challenge: Stage 3 Traversing and Manipulating the DOM with JavaScript

I can't figure out why this code challenge isn't passing. Challenge says: Take a look at the app.js and index.html. We're removing a paragraph and adding a new one to the body. The newParagraph has not text in it. On line 7 of app.js, modify the newParagraph element's text to say "JavaScript is enabled".

the code I added is:

newParagraph.innerText("Javascript is enabled");

In full context the entire code for the challenge (including my entry) is as follows:

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

// Add text to the new paragraph

newParagraph.innerText("Javascript is enabled");

//Remove "Please Enable JavaScript" paragraph

body.removeChild(pleaseEnableParagraph);

//Append new paragaph to document

body.appendChild(newParagraph);

Am I blind or just going crazy? I also tried using innerHTML and textContent with no luck either.

7 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi Liz - good to see you again!

innerText is a property and is not a method. So to assign it you use equals.

newParagraph.innerText = "Javascript is enabled";

It takes some getting used to. I still do it from time to time coming from jQuery :)

Regards
Andrew

Jason Larkin
Jason Larkin
13,970 Points

I also noticed that it wouldn't accept "Javascript" but would accept "JavaScript", with the camel case spelling.

Ian Blair
Ian Blair
7,411 Points

This also works.

body.removeChild(pleaseEnableParagraph);

CORRET IS .... newParagraph.innerText = "JavaScript is enabled";

Doh! (bangs head on computer) thanks so much!

I had the same problem that Case sensitivity OP

newParagraph.innerText = "JavaScript is enabled";

watch out for the for S on "JavaScript is enabled" not "Javascript is enabled" ! newParagraph.innerText = "JavaScript is enabled"