Skip to content

Instantly share code, notes, and snippets.

@Faldrian
Created March 4, 2021 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Faldrian/6ede1550bcdc622c89d0fa62e21b74eb to your computer and use it in GitHub Desktop.
Save Faldrian/6ede1550bcdc622c89d0fa62e21b74eb to your computer and use it in GitHub Desktop.
Little helper for figuring out anagrams...
<html>
<body>
<p>Pool: <input id="buchstaben"></p>
<p>Verbleibend: <span id="pool"></span></p>
<p><input id="genutzt"></p>
<script type="text/javascript" >
let genutzt = document.getElementById('genutzt');
let buchstaben = document.getElementById('buchstaben');
let pool = document.getElementById('pool');
genutzt.addEventListener('input', function () {
var pool2 = buchstaben.value.toUpperCase();
pool.style = '';
for (var x = 0; x < genutzt.value.length; x++)
{
var c = genutzt.value.charAt(x).toUpperCase();
if(buchstaben.value.indexOf(c) < 0) {
pool.style = 'color:red';
}
pool2 = pool2.replace(c, '');
}
pool.innerHTML = pool2;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment