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 trialLiz Karaffa
17,576 PointsCode 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
Treehouse Guest TeacherHi 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
13,970 PointsI also noticed that it wouldn't accept "Javascript" but would accept "JavaScript", with the camel case spelling.
Ian Blair
7,411 PointsThis also works.
body.removeChild(pleaseEnableParagraph);
Ary de Oliveira
28,298 PointsCORRET IS .... newParagraph.innerText = "JavaScript is enabled";
Liz Karaffa
17,576 PointsDoh! (bangs head on computer) thanks so much!
Andrew Chalkley
Treehouse Guest TeacherNo worries!
Kelli Prieto
8,515 PointsI had the same problem that Case sensitivity OP
newParagraph.innerText = "JavaScript is enabled";
Dennis Kadengu
7,611 Pointswatch out for the for S on "JavaScript is enabled" not "Javascript is enabled" ! newParagraph.innerText = "JavaScript is enabled"