August 2017
Beginner
298 pages
7h 4m
English
The first thing we want to do in our application is to load the tasks dynamically from a set of data. Let's declare a class variable that contains the data for tasks along with methods needed to pre-populate the tasks. ES6 does not provide a direct way to declare class variables. We need to declare variables using the constructor. We also need a function to load tasks into the HTML elements. So, we'll create a loadTasks() method:
class ToDoClass { constructor() { this.tasks = [ {task: 'Go to Dentist', isComplete: false}, {task: 'Do Gardening', isComplete: true}, {task: 'Renew Library Account', isComplete: false}, ]; this.loadTasks(); } loadTasks() { }}
The tasks variable is declared inside the constructor as
Read now
Unlock full access