Skip to content

Instantly share code, notes, and snippets.

@yajamon
Created July 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yajamon/118edd2af646f04ddfab to your computer and use it in GitHub Desktop.
Save yajamon/118edd2af646f04ddfab to your computer and use it in GitHub Desktop.
function isFalse (value){
if(value === false) {
return true;
}
return false;
}
function eachArray (arr, callback){
var length = arr.length;
for(var index=0; index<length; ++i){
var retValue = callback(arr[index], index);
var breakFlag = isFalse(retValue);
breakFlag ? break:;
}
}
function exists5callback (value, index){
if (value === 5) {
console.log('exists 5!');
return false;
}
}
function exists5 (arr){
eachArray(arr, exists5callback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment