Created
June 18, 2020 14:56
-
-
Save bensampaio/17bdc5ceb0af4108053ada570eb5a2d7 to your computer and use it in GitHub Desktop.
Interview questions
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
// How to optimize this function? | |
function incrementAll(list, options) { | |
return list.map((value) => { | |
value += options.add; | |
value *= options.multiply; | |
return value; | |
}); | |
} |
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
// How to optimize this component? | |
const InputField = ({ name, pattern, value }) => { | |
const [currentValue, setValue] = useState(value); | |
const handleChange = useCallback((event) => { | |
setValue(event.target.value); | |
}); | |
return ( | |
<> | |
<input name={name} value={currentValue} onChange={handleChange} /> | |
{currentValue && !pattern.test(currentValue) && ( | |
<div> | |
This is wrong, please change it. | |
</div> | |
)} | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment