Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
210,871 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
210,871 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