Undefined, not sure why? can someone give me a nudge in the right direction?

Undefined, not sure why? can someone give me a nudge in the right direction?
0

#1

Hi Guys,

I am trying to write some JS to run a todo list, heres what I have got.

var todoList = {
  todos:["item1","item2","item3"],
  displayList: function(){
  console.log(this.todos);
},

addTodo: function(todo){
  this.todos.push(todo);
  this.displayList();
},
changeTodo: function(position, newValue){
  this.todos[position] = newValue;
  this.displayList();
}
};

Whenever I try and call changeTodo in console it returns “changeTodo is undefined”

Everything else seems to work fine, I feel like I am overlooking something really obvious, or is there something I am failing to understand?


#2

Do you call your function like this?

todoList.changeTodo(3, 3)

#3

God dammit :grimacing::confounded::sob:
I’ve been trying changeTodo(1,1): completely forgot todoList.
Whats more embarrassing is I have been todoList.addTodo(1) so the answer was right there in front of me.
Damn, Do I feel dumb right now lol

But thanks for the help dude
:stuck_out_tongue: