Last active
April 26, 2024 05:22
-
-
Save fitsum/a0659c70e4338d9d4428d7fd5b36751f to your computer and use it in GitHub Desktop.
finally
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 a = [1,2,3,4]; | |
const checkType = (type, collection2check) => collection2check.every((each) => typeof each === type); | |
const curr = (collection) => { | |
return (actionOrType, actionFn) => { | |
return actionFn(actionOrType, collection) ? `all in ${collection} are ${actionOrType}s` : `few or none in ${collection} are ${actionOrType}s`; | |
}; | |
} | |
const arr = curr(a); | |
console.log(arr('number', checkType)) | |
console.log(arr('string', checkType)) | |
console.log(curr(a)('string', checkType)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment