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 trialgael blanchemain
Full Stack JavaScript Techdegree Student 8,843 PointsJavaScript Array Iteration Methods exercise....buggy?
I submitted my answer for a coding challenge (https://teamtreehouse.com/library/javascript-array-iteration-methods/combining-array-methods/combining-filter-and-map). I keep getting error " Line 24: Unexpected token ILLEGAL" but if I execute the code with node.js it passes with no error. Any hint is appreciated!
Here's my code:
const todos = [
{
todo: 'Buy apples',
done: false
},
{
todo: 'Wash car',
done: true
},
{
todo: 'Write web app',
done: false
},
{
todo: 'Read MDN page on JavaScript arrays',
done: true
},
{
todo: 'Call mom',
done: false
}
];
let unfinishedTasks;
unfinishedTasks = todos
.filter(todo => todo.done == false)
.map(todo => (`${todo.todo}`))
2 Answers
Rich Donnellan
Treehouse Moderator 27,696 PointsHey Gael,
Here is a "hint" as requested:
The todo.todo
is already a string. 🤔
John Johnson
11,790 PointsSounds like it's just a subtle discrepancy in how Treehouse interprets vs Node
You could try just rearranging the bottom few lines of code a bit. Maybe this will work:
let unfinishedTasks = todos
.filter( todo => todo.done == false )
.map( todo => (`${todo.todo}`) );
gael blanchemain
Full Stack JavaScript Techdegree Student 8,843 PointsI tried that too, to no avail, thank you for taking the time, though!
gael blanchemain
Full Stack JavaScript Techdegree Student 8,843 Pointsgael blanchemain
Full Stack JavaScript Techdegree Student 8,843 PointsGot it, removing the string literal flag worked, thank you!
Rich Donnellan
Treehouse Moderator 27,696 PointsRich Donnellan
Treehouse Moderator 27,696 PointsAwesome! Keep it up!