JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id='input'>11AAJj</textarea>
<pre id='report'></pre>
JavaScript
var r = document.getElementById('report'),
t = document.getElementById('input');
(t.onkeyup = function(e) {
r.innerHTML = getReport(t.value);
})();
function repeatedChars(s) {
var charsFound = {}, repeatedChars = '';
for (var i = 0; i < s.length; i++) {
if (charsFound[s.charAt(i)]) repeatedChars += s.charAt(i);
else charsFound[s.charAt(i)] = true;
}
return repeatedChars;
}
function repeatedAll(s) { return repeatedChars(s); }
function item(txt) { return '- ' + txt + '\n'; }
function getReport(s) {
var score = s.length,
alnum = repeatedAll(s);
return (
item(score + ' characters long') +
item('repeated characters: -' + (score -= alnum.length*1, alnum.length*1) + ' (' + alnum + ')') +
'\nTotal score: ' + score
);
}