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 trialSamuel Kleos
Front End Web Development Techdegree Student 13,409 PointsI declared the method differently. Is this proper?
Hello,
Hope you're well. I appreciate you taking a look at this. :)
I often mix up object literal method declaration, and class method declaration like below:
class Pet {
constructor(animal, age, breed, sound) {
this.animal = animal;
this.sound = sound;
}
speak() {
console.log(this.sound);
}
}
const casper = new Pet('cat','meow')
Is my solution to the code challenge correct?
const myString = {
string: "Programming with Treehouse is fun!",
countwords() {
this.string.split(" ").length;
}
}
1 Answer
Steven Parker
231,269 PointsYou're close, but the instructions ask for a method named "countWords" (with a capital "W") but this code has it in all lower case.
Also, the method needs to return the length.