basically what you need to do is to have an object where to store the additions of each letter, after that you can compare if you already have it then you add 1, if there is no entry for that, you start with 1.
take a look to the comments, you will see how it works
function problem14() {
// to hold all the letter repetitions
const letters = {};
// to get the value that the user enters
let input1 = document.getElementById('input14').value;
// loop over the input text
for (let i = 0; i < input1.length; i++) {
// save the letter that we are looking
let currentLetter = input1[i];
// lets compare, if the current letter is already counted we add 1
if (letters[currentLetter]) {
letters[currentLetter] += 1;
} else {
// this means the letter was not in our object, so we initialize it using 1
letters[currentLetter] = 1;
}
}
// the JSON.stringify function is just to show it in a readable way
document.getElementById('result').innerHTML = JSON.stringify(letters, null, 4);
}
document.getElementById("button").addEventListener("click", function() {
problem14();
});
<input id="input14">
</br>
<button id="button"> count </button>
</br>
result: <label id="result"></label>