Skip to content

Conversation

YuliaKuderko
Copy link

No description provided.

document.querySelector('ul').addEventListener('click', deleteHandler)
document.getElementById('clear-all').addEventListener('click', clearAllHandler)
document.querySelector('ul').addEventListener('click', alertMessage)
/*document.getElementById('new-task').addEventListener('keydown', preventSpace)*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid leaving those comments in the code :)

event.preventDefault() //Preventing page refresh on form submission
const newTaskInput = document.querySelector('#new-task')
listGif.style.display= "none"
if (newTaskInput.value != ''){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general its a better practice in js to use instead of == (on in this case !== instead of !=)
this way you check comparison of both the value and the type and not just the value

}

//Prevents "space" click on keyboard
/*function preventSpace(event){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here - you should keep the code clean when its ready for review without those comments
also - let me know if you need help with the what you wanted to do here :)

doneTasksCounter = 0
}
item.classList.add('task-delete-animation')
tasksCompleted.innerText = `You have completed ${doneTasksCounter} / ${tasksCounter} tasks`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are multiple places where you create this text, consider extracting to function. this way you have 1 source of truth, and if you will need to change the text - you will need to do this just in 1 place and not everywhere

Comment on lines 114 to 115
tasksCounter = 0
doneTasksCounter = 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part should not be inside the loop, it can happen just once when calling this function

</form>
<div class="tasks-container">
<ul></ul>
<img id="list-gif" src="list_gif.gif" alt="list" style="display: flex;" height="200px" width="200px">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a better practice to add class and then add the style in css. try to avoid using style attribute explicitly :)

function checkTodo(event){
let item = event.target.parentNode
//When clicking on the check button after it was already checked as done, the line through style will be removed
if(item.style.textDecoration === 'line-through'){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using early return to make the code more clear

if (something) {
.... 
return;
}
// else logic in here

@@ -1,0 +1,125 @@
document.querySelector('form').addEventListener('submit', submitButtonHandler)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are missing ; everywhere. dont forget to add it at the end of any new line in js :)


/*** Task Done Checkbox */
function checkHandler(event){
if(event.target.name === 'task-complete'){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this event is triggered in every ul selector but relevant only for task-compelte.
consider adding it specifically for the relevant selector when creating it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants