This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Prompt: | |
We have defined a basic dropdown via the Dropdown and DropdownItem components below, with example usage | |
in the ExampleNav component. The Dropdown and DropdownItem components have some problems, and also | |
have room for improvements (doesn't everything?) A couple items TODO here (make sure to explain with comments!) | |
0. How are you today? 😊 | |
ANS: Doing great and trust you're as well. | |
1. Please fix any obvious issues you see with the dropdown. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeInstances = ({arr, val}) => { | |
const arrLength = arr.length; | |
if(arrLength === 0) throw new Error("Array cannot be empty"); | |
//Return the orginal length of array if no number is passed in. | |
if(!val) return arrLength; | |
const filteredArray = arr.filter((num) => num !== val); |