Write a program which replaces all 'A's in the letter with '#' when given an uppercase letter as an argument.
Result
Solution1
function solution(str){
let answer = "";
for(let x of str){
if(x === 'A') answer += '#';
else answer += x;
}
return answer;
}
Solution2
function solution(str){
let answer = str; //making a shallow copy of the string
answer = answer.replace(/A/g, '#'); //RegExp -> find 'A' globally and replace it with '#'
return answer;
}