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 trialRob Palmer
8,358 PointsTrying to figure out why this line of code doesn't work for get unusedTokens()
get unusedTokens() { let arr = []; for(let i = 0; i < this.tokens.length; i++) { if (this.tokens[i].dropped = false) { arr.push(this.tokens[i]); } return arr; } }
1 Answer
jb30
44,806 PointsIn the line if (this.tokens[i].dropped = false)
, you have one =
, which will assign the value false
to this.tokens[i].dropped
. To check equality, try using ===
or ==
instead.
To format a block of code, you can type three backticks, `, followed by the word javascript, on the line before the code block, and three backticks on the line after the code block. To format code inline, you can type a backtick before and after the code.
Rob Palmer
8,358 PointsAwesome, I feel silly for not catching that. Thanks for the help!
Rob Palmer
8,358 PointsRob Palmer
8,358 PointsSorry first time posting a question, I didn't realize my code would get all messed up formatting-wise. I guess I could also use some help on how to fix that for next time as well!