Javescript on code pen

Hi, I wrote this code on code pen to practice Javascript, however, the console didn’t show anything. What’s wrong with my code? Or something else I did wrong? Please help. Thanks

const todo=[{
  text:'Wash the floor',
  completed:true
},{
  text:'Walk the dog',
  completed:false
},{
  text:'Do homework'
  completed:false
}]

const getThingsToDo=function(todos){
  return todos.filter(function(todo){
    return todo.completed===false
  })
}
 console.log(getThingsToDo(todos))

Can you share your codepen link ?

There needs to be a comma after ‘Do Homework’

1 Like

And todos is undefined.

I am getting messages in the console when I threw it in codepen

Then , what’s wrong with my code? How come it’s all red?

Did you understand what @jonathan.roley and @kevinSmith mentioned?

Yes, I switched the todo to todos, however nothing different happened. If it was related to undefined, the console usually would point that out. And I do not understand where’s SyntaxError came from?

},{
  text:'Do homework'.
  completed:false
}]

That needs to be a comma, not a period.

With that error still in there, the line after that is highlighted. That is CP telling you there is a problem. If you press on the red error icon, it says that there is a syntax error with the colon. Really that means that there is a syntax error before it that prevents JS from being able to properly parse the code.

1 Like

Thank you!!! But I was hoping just the ‘Do homework’ and ‘Walk the dog’ would show up in the console, see what I got. How come all those " " show up as well?

[// [object Object] 
{
  "text": "Walk the dog",
  "completed": false
},// [object Object] 
{
  "text": "Do homework",
  "completed": false
}]

I’m not sure what you mean. Do you mean the double quote signs? I assume that CP converts it to JSON. I don’t know - I normally use the browser console.

I see. Would you please tell me where can I just code and see the result, I need to practice.

It’s not that much different from what you see in the browser console. I often use codepen to try out little JS things. If I need to do more complicated things, I will open out a terminal window and work in a Node environment.

Got it! Thanks x 1000 :slight_smile: