Advent of Code - Day 5 Part 2
HTML
<textarea placeholder="Enter Input Here" rows="20" cols="50"></textarea>
<p></p>
JavaScript
$('textarea').change(function () {
var words = $(this).val().split('\n');
var niceCount = 0;
$.each(words, function (i, word) {
var duplicates = (/([a-z][a-z])[a-z]*\1/).test(word)
var repeated = (/([a-z])[a-z]\1/gi).test(word);
if (duplicates && repeated) {
niceCount++
}
});
$('p').text('Total Nice Strings : ' + niceCount);
});