Created
June 27, 2023 20:48
-
-
Save drteresavasquez/0fff67746bf34f28ee45e2bd0d6cf67e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelctor('form').addEventListener('submit', (e) => { | |
e.preventDefault(); // this prevents the form from reloading on submit | |
console.log("submitted") | |
// 1. grab the value from the form | |
const name = document.querySelector("#name").value; | |
// 2. create a new object with it | |
const newObj = { | |
name, | |
complete: false, | |
id: todoArray.length + 1, | |
} | |
// 3. push it to the array | |
todoArray.push(newObject); | |
// 4. repaint the DOM | |
todosOnDom(); | |
// 5. reset the form | |
document.querySelctor('form').reset() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment