-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathto-do-list.html
34 lines (31 loc) · 1023 Bytes
/
to-do-list.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Simple To-Do List</title>
</head>
<body>
<!--
Create a simple to-do list where users can add tasks, mark tasks as completed, and view the list of tasks.
-->
<input type="text" id="taskInput" placeholder="Enter task" />
<button onclick="addTask()">Add Task</button>
<button onclick="viewTasks()">View Tasks</button>
<script>
let tasks = [];
function addTask() {
let task = prompt("Enter task:");
tasks.push(task);
}
function viewTasks() {
alert(`Tasks:\n${tasks.join("\n")}`);
/*
In this code, the viewTasks function displays an alert with a message that includes the tasks joined
with line breaks.
The backticks () are used for template literals to embed the variable tasks` in the string.
*/
}
</script>
</body>
</html>