JavaScript Practice Object Basics in JavaScript Practicing Object Basics Practice Updating a Property's Value

bessiebarnes
bessiebarnes
83,612 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
203,693 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: