05. Render Todos πŸ‘©β€πŸŽ“πŸ‘¨β€πŸŽ“

Render Todos

In this activity, you will be writing code to render an array of todo items to the list.

Instructions

  • Open the script.js file provided to you. You have been provided the necessary variable declarations as well as an array of todo items.

  • Your goal is to create a function that will render our todos into a list in the browser.

    • Initially, set the text content of the todoList to an empty string.

    • todoCountSpan should show the total count of todos on the page.

  • Inside of your render function, you will also need a for loop.

    • It should loop over the todos array, creating an li element for each index of the array.

    • It should set the content of the created li element to the value of the current array index.

    • Finally, the new li should be appended to the ul provided.

  • Add an event listener so that, when a user hits enter, the value from the todo input field is pushed to our todo array.

  • Make sure that empty values are not pushed to the array.

  • Once the value has been added to the array, clear the input field and re-render the todoList.


βœ… Solutions

Solutions Click Here