Skip to content

Instantly share code, notes, and snippets.

@mmloveaa
Last active January 5, 2016 21:11
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 mmloveaa/575ae009ed91bf99a647 to your computer and use it in GitHub Desktop.
Save mmloveaa/575ae009ed91bf99a647 to your computer and use it in GitHub Desktop.
Lost Numbers
// 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