Challenge 1 - Reading Code & Fixing Errors

  1. Highlight the Arguments

  2. Add an asterisk (*) in front of all the function declarations

  3. Underline all the parameters

  4. Circle all the arguments

  5. Write a square bracket ( [ ] ) in front of any conditional statements & inside the brackets, indicate any operators they’re using (separate multiple with a comma)

renderTodoList(); // User clicked on the add button // If there is any text inside the item field, add that text to the todo list

document.getElementById('add').addEventListener('click', function() { var value = document.getElementById('item').value; if (value) { addItem(value); } }); document.getElementById('item').addEventListener('keydown', function(e) { var value = this.value; if ((e.code === 'Enter' || e.code === 'NumpadEnter') && value) { addItem(value); } }); function addItem(value) { addItemToDOM(value); document.getElementById('item').value = ''; data.todo.push(value); dataObjectUpdated(); } function renderTodoList() { if (!data.todo.length && !data.completed.length) return; for (var i = 0; i < data.todo.length; i++) { var value = data.todo[i]; addItemToDOM(value); } for (var j = 0; j < data.completed.length; j++) { var value = data.completed[j]; addItemToDOM(value, true); } }

document.getElementById('todo'); var item = document.createElement('li'); item.innerText = text; var buttons = document.createElement('div'); buttons.classList.add('buttons'); var remove = document.createElement('button'); remove.classList.add('remove'); remove.innerHTML = removeSVG; // Add click event for removing the item remove.addEventListener('click', removeItem); var complete = document.createElement('button'); complete.classList.add('complete'); complete.innerHTML = completeSVG; // Add click event for completing the item complete.addEventListener('click', completeItem); buttons.appendChild(remove); buttons.appendChild(complete); item.appendChild(buttons); list.insertBefore(item, list.childNodes[0]); }

Last updated