javascript: undefined variable -


my variable 'todolist' showing undefined. new javascript , programming in general. appreciated!

var todolist = {    todos:[],    displaytodos: function() {      if (this.todos.length === 0) {        console.log ('your todos list empty!');      } else {        console.log('my todos:');        (var = 0; < this.todos.length; i++) {          if (this.todos[i].completed === true) {            console.log ('(x)', this.todos[i].todotext);          } else {            console.log('( )', this.todos[i].todotext);          }        }      }    },    addtodo: function(todotext) {      this.todos.push({        todotext: todotext,        completed: false      });      this.displaytodos();    },    changetodo: function(position, todotext) {      this.todos[position].todotext = todotext;      this.displaytodos();    },    deletetodo: function(position) {      this.todos.splice(position, 1);      this.displaytodos();    },    togglecompleted: function(position) {      var todo = this.todos[position];      todo.completed = !todo.completed;      this.displaytodos();    },    toggleall: function() {      var totaltodos = this.todos.length;      var completedtodos = 0;      (var = 0; < totaltodos; i++) {        if(this.todos[i].completed === true) {          completedtodos++;        }      }      if (completedtodos === totaltodos) {        for(var =0; < totaltodos; i++) {          this.todos[i].completed === false;        }      }      this.displaytodos;    }  };

javascript returns something. if copy/paste code chrome console , run it, tells me returned result of running code undefined. that's okay, since you're setting object , have no intention of using return value.

enter image description here

after this, object has been created , typing chrome console tells variable todolist object.

enter image description here


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -