CodingNic

Basic Task Management

Create the Task Data

Basic Task Management 8 min read

Create the Task Data

Create the Task Data

Before we connect the interface to the application, create the data that will represent the tasks.

1. Open js/script.js

Open the JavaScript file from the starter project.

2. Add the Task Array

At the top of the file, add:

javascript
const tasks = [];

This array will hold the tasks while the application is running.

3. Add a Sample Task

Temporarily replace the empty array with:

javascript
const tasks = [
  {
    id: crypto.randomUUID(),
    title: "Welcome to the To-Do List",
    completed: false
  }
];

Save the file.

We will use this sample task while building the first renderer. Later, the task will come from the Add Task form instead.

Checkpoint

Your tasks array should contain one task with an id, title, and completed value.