CodingNic

Task Details and Editing

Add Task Priorities

Task Details and Editing 8 min read

Add Task Priorities

Add Task Priorities

The prepared interface also includes a priority selector. Store its value with each task.

1. Read the selected priority

The custom priority control can be accessed through the dropdown value you created for the interface. If you are following the starter project structure, use the priority dropdown value:

javascript
const priority = priorityDropdown.value;

Add it to the task object:

javascript
const task = {
  id: crypto.randomUUID(),
  title,
  due: dueInput.value,
  priority,
  completed: false
};

2. Reset the priority

After creating a task, return the selector to its default value:

javascript
priorityDropdown.value = "Medium";

3. Test all three priorities

Create several tasks and choose High, Medium, and Low before adding them.

Inspect the task data and confirm that each task stores the selected priority.

Checkpoint: Every new task has a priority value, and the add-task controls return to their default state after a task is created.