I am trying to figure out how to use character wrapping to mutate a string based on user input. If string is \'Bob loves to build building\' and user enters \'b\' I have to mak
how about:
myString = myString.replace(letter,exchange);
EDIT: myString is the string you want to replace the letter in.
letter is taken from your code, it is the letter to be replaced.
exchange is also taken from your code, it is the string that letter is to be replace with.
Of course you would need to do this again for the upper case letter and lower case so it would be:
myString = myString.replace(letter.toLowerCase(),exchange);
myString = myString.replace(letter.toUpperCase(),exchange);
In order to cover the case where the entered letter is either lower or uppercase.