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

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"