Here's an example:
var string = 'This is a text that needs to change';
var vowels = ['a','e','i','o','u'];
var numbers = [1,2,3,4,5];
var result = string.replace(/./g, function(char) {
var idx = vowels.indexOf(char);
return idx > -1 ? numbers[idx] : char;
});
//^ Th3s 3s 1 t2xt th1t n22ds t4 ch1ng2