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

Rob Palmer
Rob Palmer
8,358 Points

Trying 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; } }

Rob Palmer
Rob Palmer
8,358 Points

Sorry 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!

1 Answer

In 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
Rob Palmer
8,358 Points

Awesome, I feel silly for not catching that. Thanks for the help!