Last active
December 27, 2015 19:16
-
-
Save mmloveaa/31471a75175c912ad880 to your computer and use it in GitHub Desktop.
Friends or Foes?
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
// 12/22/2015 | |
// Make a program that filters a list of strings and returns a list | |
// with only your friends name in it. All your friends only have | |
// four letter in their name. | |
// Ex: Input = ["Ryan", "Kieran", "Jason", "Yous"], | |
// Output = ["Ryan", "Yous"] | |
// My Solution: | |
function friend(friends){ | |
var arr2=[]; | |
arr2=friends.filter(function(element){ | |
return element.length==4 | |
}) | |
return arr2; | |
} | |
friend(["Ryan", "Jimmy", "123", "4", "Cool Man"]) | |
//friend(["Ryan", "Kieran", "Mark"]) | |
// function friend(friends){ | |
// var arr1=[]; | |
// for(var i=0;i<=friends.length-1;i++){ | |
// if(friends[i].length==4){ | |
// arr1.push(friends[i]) | |
// } | |
// } | |
// return arr1; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment