Last active
December 7, 2015 04:34
-
-
Save kevinkace/290b29f89662ddfbdbe0 to your computer and use it in GitHub Desktop.
Advent of Code - 5a
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 names = document.querySelector("pre").innerHTML.trim(), | |
niceCount = 0; | |
function vowelCheck(name) { | |
var count = name.match(/[aeiou]/gi); | |
return count && count.length >= 3; | |
} | |
function doubleCheck(name) { | |
return /(.)\1/.test(name); | |
} | |
function excludeCheck(name) { | |
return !/ab|cd|pq|xy/.test(name); | |
} | |
console.log(names.split("\n").filter(function(name, idx) { | |
var result = vowelCheck(name) && doubleCheck(name) && excludeCheck(name); | |
// console.log(name + ":" + result); | |
return result; | |
}).length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment