for learning purposes I want to remove only the FIRST letter 'a' from a string using a function. My function however removes ALL letters 'a' from the given string.
function removeFirstLetterA(str) {
let letterA = 'a';
for (let i = 0; i < str.length; i++) {
if (str[i] === letterA) {
str = str.replace(letterA, '');
}
}
return str;
}
Can anyone see my mistake and give any tips?