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

Friday, May 12, 2017

FreeCodeCamp Mutations Sample Solution



function mutation(arr) {
  var arr1 = arr[0].toLowerCase().split('');
  var arr2 = arr[1].toLowerCase().split('');
  var temp = false;
  for(var i=0; i<arr2.length; i++){
    temp = false;
    for(var j=0; j<arr1.length; j++){
      if(arr2[i] === arr1[j]){
        temp = true;
      }  
    }
    if(temp === false){
      //all the letters in the first word didn't match
      break;
    }
  }
  return temp;
}

mutation(["hello", "Hello"]);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts