Skip to content

Commit

Permalink
Merge pull request #1 from mnashawati/master
Browse files Browse the repository at this point in the history
Updating study branch
  • Loading branch information
mnashawati authored May 29, 2020
2 parents c4cd2f4 + b527c7f commit 57dd14a
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,25 @@ function App() {
return "";
}

// function handelSearch(e) {
// const searchTerm = e.target.value;
// }

const filterAndUpdateCurrentNames = (nameObjects) => {
let searchResult = nameObjects.filter((obj) =>
const searchResult = nameObjects.filter((obj) =>
obj.name.toLowerCase().includes(searchTerm.toLowerCase())
);
return searchResult;
};

// function checkGender(array) {
// if array.filter((element) => element.sex === "m");
// }
const handleSearch = (e) => {
setSearchTerm(e.target.value);
setCurrentNames(filterAndUpdateCurrentNames(currentNames));
};

return (
<div className="App">
<input
className="search-input"
placeholder="search names"
value={searchTerm}
onChange={(e) => {
console.log(e.target.value);
setCurrentNames(() => filterAndUpdateCurrentNames(sortedNames));
setSearchTerm(e.target.value);

// debugger;
// filterAndUpdateCurrentNames(sortedNames);
}}
onChange={handleSearch}
></input>
<div className="radio male-names">
<label>
Expand Down

0 comments on commit 57dd14a

Please sign in to comment.