Last active
August 29, 2015 14:19
-
-
Save karenpeng/9fe4559cee213455d791 to your computer and use it in GitHub Desktop.
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
var test = [1,2,3] | |
function check(arr){ | |
arr.forEach(function(el){ | |
if(el === 2){ | |
console.log('ouch') | |
return true; | |
} | |
}) | |
return false; | |
} | |
function check1(arr){ | |
for(var i = 0; i < arr.length; i++){ | |
if(arr[i] === 2)return true; | |
} | |
return false; | |
} | |
check(test) //ouch false | |
check1(test) // true | |
//one more layer needs to be return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment