Created
May 11, 2016 08:49
-
-
Save zaycker/c978aff38f08813cc6bf2e72a10f2c7b to your computer and use it in GitHub Desktop.
MyxvmR
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
var bbb = [1,1,1,1,2,2,3,3,3,3,4,4,5,5,7,7,7,7].filter(function(element, index, array) { | |
switch (true) { | |
case (array.lastIndexOf(element) - array.indexOf(element) > 1): | |
// there are more than 2 such elements | |
return false; | |
case (array.indexOf(element) === index): | |
// there are 1 or 2 such elements | |
return true; | |
default: | |
return false; | |
} | |
}); | |
console.log(bbb); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment