Last active
January 5, 2016 21:11
-
-
Save mmloveaa/575ae009ed91bf99a647 to your computer and use it in GitHub Desktop.
Lost Numbers
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
// 1/5/2016 | |
// Lost Numbers | |
// Write a function that determines whether a given number is part of an array of lost numbers. | |
// If it is a lost number have the function return true and if it is not then return false. | |
// Note: This kata is inspired by the first coding problem I ever solved on Codecademy. | |
// Surprisingly I couldn't find it on Codewars so now its here for everyone. If you can't | |
// solve the problem then work through this tutorial | |
// http://www.codecademy.com/courses/functions-in-javascript-2-0/0/1?curriculum_id=4f4bdd96848740000300026a | |
// Test.expect(isLost(23),true) | |
// My Solution | |
var lost = [4, 8, 15, 16, 23, 42]; | |
function isLost(num){ | |
if(lost.indexOf(num)===-1){ | |
return false; | |
}else{ | |
return true; | |
} | |
} | |
isLost(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment