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 trialNnanna Okoli
Front End Web Development Techdegree Graduate 19,181 PointsApp not working ..
app.js:59 Uncaught ReferenceError: element is not defined at appendToLI (app.js:59:24) at createLI (app.js:66:3) at HTMLDocument.<anonymous> (app.js:87:14)
Please could you help me understand what the error is here, as I understand the purpose of this task is DRY. But I'm quite confused by this tutorial and struggle to resolve the error.
Thank you in advance, please see the link below. https://w.trhou.se/vdf5jafczn
1 Answer
jb30
44,807 PointsThe reference error means that Javascript can't find the variable named element
.
function appendToLI(elementName, property, value) {
const span = createElement(elementName, property, value);
// to add the text to the list element
li.appendChild(element);
return element;
}
In the first line of the function, the variable span
was created. In the lines after the comment, the variable element
is used instead. Try changing span
to element
or element
to span
so that all three lines of code use the same name for the variable.
Nnanna Okoli
Front End Web Development Techdegree Graduate 19,181 PointsNnanna Okoli
Front End Web Development Techdegree Graduate 19,181 PointsYeah, that makes sense, thanks for the feedback. Its much appreciated!