@@ -11,14 +11,15 @@ const noTasksMessage = `<div class="completed">
1111 <p>Add a task to plan your day.</p>
1212 </div>` ;
1313
14+ // if user clicked on uncheck or check icon, format the task accordingly
1415const completedTask = ( task ) => {
1516
1617 const uncheckIcon = task . querySelector ( "i.pendingSvg" ) ;
1718 const editIcon = task . querySelector ( "i.editSvg" ) ;
1819
1920 if ( uncheckIcon . className === taskUncompletedIcon )
2021 {
21- // update icon, disable edit
22+ // update icon, text and disable edit
2223 uncheckIcon . className = taskCompletedIcon ;
2324 editIcon . style . display = "none" ;
2425 task . classList . add ( "checked" ) ;
@@ -34,7 +35,7 @@ const completedTask = (task) => {
3435 }
3536 else
3637 {
37- // update icon, enable edit
38+ // update icon, text and enable edit
3839 uncheckIcon . className = taskUncompletedIcon ;
3940 editIcon . style . display = "block" ;
4041 task . classList . remove ( "checked" ) ;
@@ -45,6 +46,7 @@ const completedTask = (task) => {
4546 }
4647}
4748
49+ // edit the task text when clicked on editIcon
4850const editTaskText = ( task ) => {
4951
5052 // make the task text editable
@@ -69,6 +71,7 @@ const deleteTask = (task) => {
6971 updateTaskCount ( ) ;
7072} ;
7173
74+ // add new task to the list when clicked on plusIcon or pressed Enter key
7275const addNewTask = ( ) => {
7376 // get input field value
7477 const newTask = taskInput . value ;
@@ -149,7 +152,7 @@ const updateTaskCount = () => {
149152 else
150153 taskCountText . textContent = `You have ${ taskCount } pending tasks` ;
151154
152- // check for no tasks in list
155+ // check if noTasksMessage can be added
153156 if ( taskCount < 2 )
154157 updateNoTaskMessage ( ) ;
155158}
@@ -163,6 +166,7 @@ const updateNoTaskMessage = () => {
163166 else if ( taskCount === 1 )
164167 {
165168 try {
169+ // if newTask is added remove the noTasksMessage
166170 const removeMessage = taskContainer . querySelector ( ".completed" ) ;
167171 removeMessage . remove ( ) ;
168172 }
0 commit comments