I am trying to achieve the following output but keep coming up short. Not sure I am taking the correct approach on this one. I looking to only allow only letters in the field also.
Html:
<input type="text" id="input-field" onkeyup="myFunction()">
Js:
const remDup= s=> s.split("").filter((e,i,f)=>f.indexOf(e)==i).sort().join("")
const myFunction = (e) => {
let str = document.getElementById('input-field').value
//Only allow letters no other characters
if(("abcdefghijklmnopqrstuvwxyz ").indexOf(String.fromCharCode(e.keyCode))===-1){
e.preventDefault();
return false;
}
console.log(remDup(str))
}