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

DOM Scripting By Example

TASK:

Create a function called addItem which takes a user's input and appends it to the browser's DOM, displaying it as a to-do list item.

JS CODE:

function addItem() { // TODO: add 'item' to the list of TODOs

//Step 1: identify the value of the myInput element.

//Step 2: Create a text node containing that value

//Step 3: Create a new li element and append the text node to it

//Step 4: Append the li element to the existing myTODOs element. }

//don't change this line if (typeof module !== 'undefined') { module.exports = addItem; }

Any hints and or suggestions is very much appreciated, thank you in advance for your help.

1 Answer

Cas F
seal-mask
.a{fill-rule:evenodd;}techdegree
Cas F
Full Stack JavaScript Techdegree Student 21,170 Points

Hello, The question is a bit vague, but based on the information given I suggest working through the following TreeHouse course if you'd like to learn or take refresher on DOM manipulation: Javascript and the Dom

This line does confuse me a bit: "(typeof module !== 'undefined') { module.exports = addItem; }". Google searches would indicate this is used with Node.js. If so, I haven't gotten that far yet so can't be much help in that regard.

Good luck and have fun!

Cas