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 trialneoty888
23,973 PointsHaving problems with this task. Not sure if my dot.notation is correct
"Inside the play method, write an empty if statement that checks if it's the players turn. Use dot notation."
const player1 = {
name: 'Ashley',
color: 'purple',
isTurn: true,
play: function(){
// write code here.
if (player1.isTurn) {};
}
}
Mauricio Hernandez
7,208 PointsGod bless you and your family.
19 Answers
Antti Lylander
9,686 PointsYou should use 'this' instead of 'player1' in the conditional.
Teacher Russell
16,873 PointsWhere was 'this' covered in this course, or in this js track prior to this challenge? I'm aware of it, but have no recollection of covering it in any course up until now.
the desiinger
850 PointsWhy was the ‘this’ keyword used instead of the player1?
Gonzalo Torres del Fierro
Courses Plus Student 16,751 Points"this " work for me... const player1 = { name: 'Ashley', color: 'purple', isTurn: true, play: function(){ // write code here. if (this.isTurn) {}; } }
Mauricio Hernandez
7,208 PointsGod bless you and your family.
rudyolsson
Full Stack JavaScript Techdegree Student 18,111 Pointshttp://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/ Some explanations for the uses of 'this' if anyone is confused.
Kyla Bowers
14,564 PointsThank you so much for this! console.log("You are the best");
Darren Ward
12,025 PointsThese style of these questions are frustrating to say the least. When did you mention "this" in the last video?
Óscar Hernández sandoval
9,257 PointsSorry for you feel fustrated with this answer, I posted from my cellphone. Here I post a link about "this" understanding the keywords. https://medium.com/quick-code/understanding-the-this-keyword-in-javascript-cb76d4c7c5e8
Jared Ledbetter
21,672 PointsI had this same problem. This was my solution.
const player1 = {
name: 'Ashley',
color: 'purple',
isTurn: true,
play: function(){
if(this.isTurn) {
return this.name + " is now playing!";
}
}
}
Vahe Gharagiozyan
10,088 Pointsty Jared!
Daniel Medley
5,948 PointsThey never explained 'this' in any course. Wow this site is going down hill fast.
Mauricio Hernandez
7,208 PointsThank you and God bless you and your family.
Antonio De Rose
20,885 Points//actually, it is asking for the keyword to access the property and methods, without directly
//accessing the literal, it is not wrong, but using the keyword is the best practice
//this keyword
const player1 = {
name: 'Ashley',
color: 'purple',
isTurn: true,
play: function(){
// write code here.
if (player1.isTurn) {};
}
}
Alan McClenaghan
Full Stack JavaScript Techdegree Graduate 56,501 Pointsif (this.isTurn) {};
finally worked for me in the challenge
However, if ( this.isTurn ) {};
didn't work.
Don't know why it doesn't like the spaces.
It worked fine in workspaces, as did using player1.isTurn
as in the following example:
const player1 = {
name: 'Ashley',
color: 'purple',
isTurn: true,
play: function(){
if ( player1.isTurn ) {
console.log("true");
} else {
console.log("false");
};
}
}
player1.play();
Yiwen Wei
7,993 Pointsthe same here. not like the space.
Khalid Nahary
419 PointsIt's a bit silly. "This" was not covered yet that works??
Michael Vautour
Front End Web Development Techdegree Student 9,241 PointsCan this course lecture series cover what 'this' relates to before presenting this challenge?? The lessons didn't cover this subject yet the outcome of the challenge expected it. The only reason I had any idea this was involved was due to the error.
Roald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,544 PointsOh, how I love getting the code challenge right but their own if statements to check if the questions was answered correctly only has one or 2 correct ways when in reality there are 10 ways to do this.
It's simple enough to add a few || or operators and at least half of the possible correct answers... This is just lazy.
neoty888
23,973 PointsThanks for the assist everyone. Much appreciated.
Dee Z
Full Stack JavaScript Techdegree Student 9,105 Pointsconst player1 = { name: 'Ashley', color: 'purple', isTurn: true, play: function(){ // write code here. if(this.isTurn) { return this.name + " is now playing!"; } } }
lateef Adesoji adekunle
9,179 PointsI agree with Russell and besides it didn't work. I m getting more frustrated. ?
anns
Full Stack JavaScript Techdegree Student 10,874 Pointsplay: function(){ // write code here. if (this.isTurn) {}; }
nicolabell
18,212 PointsThe last challenge is requesting bracket notation but accepts dot notation. Bit poor.
Óscar Hernández sandoval
9,257 Pointsthis my solutions:
const player1 = { name: 'Ashley', color: 'purple', isTurn: true, play: function(){ if(this.isTurn){
};
}
}
Darren Ward
12,025 PointsOscar not frustrated with you. The video doesn't mention this.
Molly Zalman
Full Stack JavaScript Techdegree Student 12,522 PointsYeah for sure agree, where is 'this' used?
Daniel Medley
5,948 PointsThey never covered it. This site is going down hill. They fired most of their teachers and staff.
Edward Crawford
5,640 Pointsthis "turn" situation has frustrated me as well!
lateef Adesoji adekunle
9,179 Pointslateef Adesoji adekunle
9,179 PointsI have the same understanding as you but I don't really know what is expected. I am not really impressed with some of the treehouse questions. They are sometimes frustrating, time wasting and moral killing. Imagine spending hours trying to get answers to simple questions like this.