Sort Tasks with Conditional Logic

GolangGolangBeginner
Practice Now

Introduction

In this challenge, you are developing a task management system for a small team. Your goal is to create a program that categorizes tasks based on their completion status using Go's conditional logic. The task is to implement the sortTask function to categorize tasks into "To Do", "In Progress", and "Completed" lists based on the input task status.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL go(("Golang")) -.-> go/DataTypesandStructuresGroup(["Data Types and Structures"]) go(("Golang")) -.-> go/FunctionsandControlFlowGroup(["Functions and Control Flow"]) go/DataTypesandStructuresGroup -.-> go/strings("Strings") go/FunctionsandControlFlowGroup -.-> go/for("For") go/FunctionsandControlFlowGroup -.-> go/if_else("If Else") subgraph Lab Skills go/strings -.-> lab-436418{{"Sort Tasks with Conditional Logic"}} go/for -.-> lab-436418{{"Sort Tasks with Conditional Logic"}} go/if_else -.-> lab-436418{{"Sort Tasks with Conditional Logic"}} end

Sort Tasks with Conditional Logic

You are developing a task management system for a small team. Your goal is to create a program that categorizes tasks based on their completion status using Go's conditional logic.

Tasks

  • Implement the sortTask function to categorize tasks using if-else statements
  • Create different task categories: "To Do", "In Progress", and "Completed"
  • Ensure the function returns the correct task list based on the input status

Requirements

  • Use the provided task_sorter.go file in the ~/project directory
  • Implement the sortTask function with if-else statements
  • The function must handle at least three task statuses: "todo", "in_progress", "completed"
  • Return the appropriate list name for each status
  • Use lowercase status strings for comparison

Examples

Use the following examples to test your implementation:

func main() {
    fmt.Println(sortTask("todo"))
    fmt.Println(sortTask("in_progress"))
    fmt.Println(sortTask("completed"))
}

To run the program, use the command:

go run task_sorter.go

Expected output:

To Do List
In Progress List
Completed List

Hints

  • Remember to use lowercase for status comparison
  • Pay attention to the exact spelling of status strings
  • Use if-else statements to handle different task statuses
โœจ Check Solution and Practice

Summary

In summary, this challenge requires you to create a program that categorizes tasks based on their completion status using Go's conditional logic. The key tasks are to implement the sortTask function to handle different task statuses, such as "todo", "in_progress", and "completed", and return the appropriate task list name for each status.