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

gael blanchemain
seal-mask
.a{fill-rule:evenodd;}techdegree
gael blanchemain
Full Stack JavaScript Techdegree Student 8,843 Points

JavaScript 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
MOD
Rich Donnellan
Treehouse Moderator 27,696 Points

Hey Gael,

Here is a "hint" as requested:

The todo.todo is already a string. 🤔

Sounds 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}`) );