Last active
August 29, 2015 14:02
-
-
Save macikokoro/35ce2ebd53abf5ab88cd to your computer and use it in GitHub Desktop.
Array and loop combination
This file contains hidden or 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 lost = [4, 8, 15, 16, 23, 42]; | |
var count = lost.length; | |
var isLost = function (n) { | |
for (var i = 0; i < 6; i++ ) { | |
if ( n === lost[i]) { | |
return true; | |
} | |
} | |
return false; | |
}; | |
if ( isLost(12) ) { | |
console.log('12 is a lost number'); | |
} | |
if ( isLost(16) ) { | |
console.log('16 is a lost number'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment