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 trialSrdjan Cestic
6,855 PointsPassing parameters to function
this.deleteTodo = function(todo) {
console.log("The " + todo.name + " todo is deleted!");
};
this.saveTodo = function(todo) {
console.log("The " + todo.name + " todo is saved!");
};
Can somebody explain why we set ''todo'' as parameter? Is that because we create ''todo'' object in HTML file(todo.name ; todo.completed)?
Thanks in advance
1 Answer
Chyno Deluxe
16,936 PointsThey todo variable is an object with different properties. We pass the entire object so that we are given access to all of its properies like todo.name rather then only passing a specific property.
Srdjan Cestic
6,855 PointsSrdjan Cestic
6,855 PointsThanks Chyno :)