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 Practice Object Basics in JavaScript Practicing Object Basics Practice Adding a Method to an Object Literal

Your countWords() method is not returning the correct number of words.

not sure why im getting this Bummer any assistance is appreciated

mystring.js
const myString = {
    string:"Programming with Treehouse is fun!",
  countWords: function () {
    return this.string.length
  }

}

She says "call a method" when she's really requesting us to create a function. This is a mistake on the instructor's behalf. This frustration had no educational value. Please correct this BS!

1 Answer

You should count the number of words in the string, not how long the string is. Hint: .split(" ")

ahhh return this.string.split( ' ' ).length thank you that worked