Skip to content

Instantly share code, notes, and snippets.

@fitsum
Last active April 26, 2024 05:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitsum/a0659c70e4338d9d4428d7fd5b36751f to your computer and use it in GitHub Desktop.
Save fitsum/a0659c70e4338d9d4428d7fd5b36751f to your computer and use it in GitHub Desktop.
finally
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