Giter VIP home page Giter VIP logo

javascript's Introduction

Multiple Filters

In this activity, we will add the ability to also filter our data by 'City'.

Instructions

  1. Open index.js and take a moment to study the new code. Currently, we are only able to search for addresses by 'State'.

  2. Within index.html, create a new input field that will be used to search for addresses by 'City'. Give this element a unique class name before moving back into index.js and creating a querySelector which stores a reference to the element within the variable $cityInput.

  3. Add code to the handleSearchButtonClick function to capture the value of the $cityInput into a new variable. Reassign filteredAddresses to be a new array containing only the addresses who's state is equal to the value of the $stateInput and who's city is equal to the value of $cityInput. Call renderTable in order to update the page.

Bonus

  • Add code to so that the partial filter matches can be made instead of exact filter matches. e.g ca should match California, ne should match New Jersey, and empty strings should match everything.

Hints

  • Filtering the array can be done with an if statement inside of a for-loop. But consider using Array.prototype.filter

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.