How can I replace A With B in the string:

I used this JavaScript code:

var Y=X.replace('A','B');

but it is replace one letter only from the string ... I want to replace all A with B.