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 Object-Oriented JavaScript Working with Classes in JavaScript Adding Methods To Our Class

Nicholas Wallen
Nicholas Wallen
12,278 Points

Why use: console.log(this.sound);?

Not sure what the purpose of adding this was.

If you delete that line from the speak() method, it does the same thing.

3 Answers

steven but what is the purpose of the method itself it doesn't make sense we still can use the sound in the constructor without any method

Steven Parker
Steven Parker
231,269 Points

The main use of "console.log" is to track program progress during development. It's not generally used in final release code.

Steven Parker
Steven Parker
231,269 Points

The "console.log" is what causes the "sound" message to appear on the console.

If the message was shown after you deleted the line, you probably forgot to save your change in the editor (with the menu or Ctrl-S shortcut) before re-running the program.

Mostafa Mekawy sound paramaters in the constructor is not directly related to the speak method... you could console.log any of the other parameters