//Get message from textarea
var msg = $('#mytextarea').val();
//Convert string to array of letters
// eg. cata = ['c','a','t','a']
var msgLettersAsArray = msg.split('');
What I need to do now is replace the single letters,something like this
c = b;
a = e;
t = c;
a = e;
//array neeeds to be converted from this:
var array = ['c','a','t','a'];
// to this:
var array = ['b','e','c','e'];
Is there any way to achieve this? All I need to do is replace the letters that are already in the array with letters of my choice
msg.replace(/c/g, 'b')replace():var map = {c: 'b', a: 'e', t: 'c'};msg.replace(/[a-z0-9]/g, function (i) { return map[i] || i; })