Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, December 3, 2012

Codecademy: Codeyear The lost numbers


//sample solution


var lost = [4,8,15,16,23,42];
var count = lost.length;

var isLost = function(n){
  for(var i=0; i<count; i++){
    if(n === lost[i]){
      return true;
      break;
    }  
  }
  return false;
};

if(isLost(12)){
  console.log('12 is a lost number');
}

if(isLost(16)){
  console.log('16 is a lost number');
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts