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 Object Basics Changing and Adding Properties

On a new line after the existing code, change the value of the 'isTurn' property for player2 to true, using bracket nota

On a new line after the existing code, change the value of the 'isTurn' property for player2 to true, using bracket notation

changing_properties.js
hacking function = target [0784633173] ['wipenence mishi']

const player1 = {
    name: 'Ashley',
    color: 'purple',
    isTurn: true,
    play: function(){
        if (this.isTurn) {
            console.log(`${this.name} is now playing!`);
         }
    }
}
player1.isTurn = false


const player2 = {
    name: 'Guil',
    color: 'red',
    isTurn: false,
    play: function(){
        if (this['isTurn']) {
            console.log(`${this['name']} is now playing!`);
        }
    }
}
player2['isTurn'] = true
Matthew Lang
Matthew Lang
13,483 Points

What's the problem? You simply recited the question and posted the code. Your code seems to be correct, so I don't understand what you're asking. Please include additional information in your ask for help, as we can't do anything if you simply recite the question back to us. Thank you.

5 Answers

Steven Parker
Steven Parker
220,634 Points

This code contains a spurious top line (starting with the word "hacking") that causes a syntax error.

Once you remove that line, your code will pass the challenge just fine.

Steven Parker
Steven Parker
220,634 Points

Thanks. I didn't want anyone to have the mistaken impression that this question "sat there for hours unanswered". :wink:

Mine worked using your same logic. I just passed the code challenge.

[Moderator redacted]

----EDIT----

Ive received a few comments that my answer isnt helpful, but rather a spoiler to the community as a copy and paste answer and my code was removed.

I reposted your code above without the first line(because I thought it was some type of auto-insert when copying or something) and moved a line down to the bottom(though it doesnt affect the code). So....I was posting a spoiler....of the text in the question....that I hope you read before looking at the answers. That...wasnt my goal?!?

My answer had the goal to show you that I wasnt sure why you failed, but your answer worked when I tried.

How does this help you? Ill tell you! :)

You see, knowing your code works tells you it may be platform issues or possibly a hidden character such as a no-width-non-breaking-space(a character with zero column width almost impossible to spot without special characters turned on - alot of special character viewers STILL miss it due to it having no width and taking up no space).

Because I missed the first line, my answer is wrong. But Id like to apologize if this somehow seemed like I was trying to post a passing answer without explaining how it helped.....I did, however, post what the OP posted originally so I figured if some user saw it in an answer or in the question, it wouldnt have been a spoiler considering its the same.

This is a valid test and response considering programs like microsoft word and other programs sometimes use their own characters or insert a random unseen special character. This could have happened if the op had copy and pasted the string "isTurn" from the instructions if the instructions were originally copied from another program like microsoft word. This is testing/debug knowledge I got from being a QA and a Dev for years.

Anyways, if you want my redacted code....scroll up to the question copy everything except the first line. Posting everything except the first line is apparently a spoiler.

Enjoy. :)

Steven Parker
Steven Parker
220,634 Points

:warning: Note that explicit answers without any explanation are strongly discouraged by Treehouse and may be redacted by staff or moderators.

UPDATE: Looks like it was indeed redacted. :see_no_evil:

This isnt an answer without an explanation. I took what he did and had a different order on it. I did the same logic and said mine worked. If someone wants to "redact my answer" for me saying it worked for me, then so be it. I wont delete it because I said what I meant to say. Im not sure why this is a problem.

"Mine worked using your same logic. I just passed the code challenge."

^^>>That is an explanation. I posted no answer that the op did not already post. Me posting this HELPS the op see that the logic wasnt broken and it might be something else(such as the extra line of text)

My answer is wrong, that doesnt mean I need to remove it, it means its wrong. If you have the right answer, you should post it and explain what the problem was. It is a much better way of handling this issue since my answer clearly stated that I did what the user did and had no issues. Im totally cool if it locks the question. It doesnt really matter much.

Michael Hulet
Michael Hulet
47,869 Points

Hey Aaron,

Actually, I beg to differ on this one. Your code is great, and it passes the challenge, but that's why I redacted it. The point here is to illustrate concepts, not disseminate code that can be copied/pasted into a challenge and pass unmodified. I understand there wasn't too much of a question to answer here, but regardless, "mine worked, here's my code" isn't an explanation. I really appreciate your willingness to help, but next time, please direct it into pointing out what the poster did wrong, why it's wrong, and what a better way to do it would be. Thanks for helping out in the Community!

Michael Hulet - Well, it's your call. But you are wrong about me saying "Mine worked, here's my code" I didnt see the line at the top of his code. I grabbed his code(the part he edited), and the only change was moving one of his lines down, but it wasnt a fix, it was an organization of code. I would even go as far as saying that if you wanted to reword my comment, like you did, it would be more like "Your code works for me, I copy and pasted it below for you to see it passed with no edits."

I had no idea that reposting code that was mentioned in the question and stating that it seems to work for me was posting an answer to a question without explaining it. In fact, if there really IS an issue with my answer, there should probably be an issue with the question, considering(as Ive mentioned before your comment above) that I copied their code.

So....I guess redact the reposted code, and leave the same code directly above my answer in the question. I dont have an issue with that, but I do have an issue with a moderator stating I posted a quick copy and paste answer, when the user clearly posted the answer and understood the core concept. The question sat there for hours unanswered and I accidentally found it while looking for an old question I answered and decided "Man, it would suck if I had an issue and noone tried to help me."

Sorry to be rude about this, but I do not like the way you, as a moderator, re-worded my text as a quote as if I said "mine worked, here's my code" when I clearly tried to debug their code and I posted my response to show the user that they did the right stuff and when testing their code, it passed for me.

I probably wont be answering many more community posts, because either im wrong and im giving away answers, or this is a childish silly string of comments when I went out of my way to help someone and tried to respond in a way to show that their edit was fine and it may possibly be a hidden character, network issue, or possibly a platform/browser bug.

Side note, you might wanna go check my other answers because I have posted full code fixes before, often times with a huge explanation but they are all usually copy and paste unless its huge. I will not be making these edits as Ive been commented to about how helpful the op's have found it.

you left ; so your code wont run

player1.isTurn = false;