TODO App

 HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TO DO app</title>
</head>
<body>
    <h1>To Do app</h1>
    <h2>list-To print all tasks</h2>
    <h2>add-To add a task</h2>
    <h2>delete-To delelte a task</h2>
    <h2>quit-To quit from the game</h2>
<script src="TODOapp.js"></script>
</body>
</html>

JS

let todo = [];
let req = prompt("Enter Request:");

while (true) {
  if (req == "quit") {
    console.log("Quitting Game...");
    break;
  }
 else if (req == "list") {
    console.log("----------");
    for (let i = 0; i < todo.length; i++) {
      console.log(i, todo[i]);
    }
    console.log("----------");
  }
 else if (req == "add") {
    let task = prompt("Enter Task:");
    todo.push(task);
    console.log("Task Added");
  } else if (req == "delete") {
    let idx = prompt("Enter the index you want to delete:");
    todo.splice(idx, 1);
    console.log("Task deleted");
  } else {
    console.log("Invalid Request!");
  }
  req = prompt("Enter Request:");
}




Comments

Popular posts from this blog

Callback Hell

TODO list with DOM

Refactoring callback hell code