- A React component can only return one parent element.
return <h1>Hello</h1><p>World</p> // error
return <div><h1>Hello</h1><p>World</p></div> // okay - JavaScript expressions can be interpolated in JSX with
{}
| /** | |
| * Filters an array of objects using custom predicates. | |
| * | |
| * @param {Array} array: the array to filter | |
| * @param {Object} filters: an object with the filter criteria | |
| * @return {Array} | |
| */ | |
| function filterArray(array, filters) { | |
| const filterKeys = Object.keys(filters); | |
| return array.filter(item => { |