Learn localStorage by Building a Todo App - Step 10

Tell us what’s happening:

Hi, I hope someone can help me with this question.
For the challenges 6 throught 9, when creating event listeners, why some of them required curly bracket "{} ", and some of them dont?
(challenges 6 and 8 dont ask for curly brackets, but 7 and 9 does)

Your code so far

openTaskFormBtn.addEventListener(“click”, () =>
taskForm.classList.toggle(“hidden”)
);

closeTaskFormBtn.addEventListener(“click”, () => {
confirmCloseDialog.showModal();
});

cancelBtn.addEventListener(“click”, () => confirmCloseDialog.close());

discardBtn.addEventListener(“click”, () => {
confirmCloseDialog.close();
taskForm.classList.toggle(“hidden”);
});

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region



// User Editable Region

Challenge Information:

Learn localStorage by Building a Todo App - Step 10

Arrow functions where the body of the function is a single expression do not need to be in blocks with curly braces {}. The function will also “implicitly return” whatever is the value of that expression. That is to say, it returns the value without having to write the return key word in front of it. If the body of the function is more than a single expression, it must be contained in curly braces {} per usual.

Read more about it here.

1 Like

Thank you very much Spooky, I appreciate the explanation.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.