Skip to content

Instantly share code, notes, and snippets.

View AbdQaadir's full-sized avatar
☺️

Lateef Quadri Olayinka AbdQaadir

☺️
View GitHub Profile
@AbdQaadir
AbdQaadir / chameleon-react.js
Created June 25, 2021 20:57
Lateef Quadri's Chameleon React technical exercise
/*
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.
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);