Giter Club home page Giter Club logo

todom's Introduction

ToDOM

An exercise in putting todo lists on the DOM.

Basic Steps

  • First, let's rewrite our printTodo function so that it takes in a string and, instead of console.logging it, adds it as innerText to an li that we append to our ul.
  • Now our print-everything function should, since it's using printTodo internally, put everything from our todo list on the DOM!
  • Now let's write a function that can clear the ul of lis.
  • Now one more function that ties that all together - a function that calls the dom-clearing-function followed by the print-all function. Now we can always call that function to refresh our DOM, removing anything in our user's todo list and repopulating it based on todos.
  • Okay, almost done. Now we'll query the add button and give it an event listener function that 1) grabs the value from the add value user input box, 2) calls your add-to-the-array function, 3) calls your add-to-the-dom function, and, finally, clears the input box so what they typed in doesn't stick around and get in the way of the next todo.
  • Last one! Query the dom for the remove button and give it an event listener function that 1) grabs the value of the OTHER input box, 2) calls your remove-from-the-array function, 3) calls your refresh-the-list function to populate the DOM with the updated version of our list that no longer includes the one you removed from the array, and, finally, 4) clears the input box of leftover text.

Stretch Goals

  • Add some flexbox or grid so that our list looks good. Consider the type of spacing you want for your items, your input boxes, your title, and so on.
  • Number the todo items (you don't have to use JavaScript for this, though you could) and ask the user for the number they want to remove, not the index. You'll have to translate the user's input to remove the correct element from the array--humans and robots count differently!
  • Make it so that we can click on a todo list item to remove it instead of asking your user to type in a number. That's just awkward!
  • Add a button to delete all items. ("Clear List", maybe?). Make sure you're removing them from the DOM and the array. You already have a function to remove all items from the DOM!

todom's People

Contributors

abbreviatedman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.