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 Updating a Property's Value

bessiebarnes
bessiebarnes
88,917 Points

Can you spot my error? I am following the solution in the video but I can't seem to get my code to pass.

Practice Object Basics in Javascript Challenge Task 1 of 1 After the object literal, change the value of myString's string property to "I love full stack JavaScript" My code is below:

const myString = { string: "Programming with Treehouse is fun!", countWords: function(){ const wordArray = this.string.split(' '); return wordArray.length; } } const numWords = myString‘countWords’; myString.characters = myString.string.length;

myString.string = "I love full stack JavaScript!”;

mystring.js
const myString = {
    string: "Programming with Treehouse is fun!",
    countWords: function(){
        const wordArray = this.string.split(' ');
        return wordArray.length;
    }
}
const numWords = myString[countWords]();
myString.characters = myString.string.length;

myString.string = "I love full stack JavaScript!;

1 Answer

Steven Parker
Steven Parker
231,269 Points

Close, but there's a few issues:

  • always use normal "programmer" quotes instead of word-processor type ("curly") quotes
  • don't change any of the code originally provided by the challenge
  • the string the instructions ask for has no punctuation in it (specifically, no "!")

The quote differences may be hard to see, so here's some examples in a larger font:

  ' :point_left: use these, not these :point_right: ’   " :point_left: and these, not these :point_right: