How can I change every specific value within an array to another specific value? My function splits a string into an array, and if a specific index == "T" it's supposed to change that value to "U", join the values in the array, and return the result. But the value "T" isn't changing within the array as I loop through it. What am I doing wrong?
function DNAtoRNA(dna) {
let array = dna.split();
let rna = "";
for(var i = 0; i < array.length; i++) {
if(array[i] == 'T') {
a[i] = 'U';
}
}
rna = array.join();
return rna;
}
Example input = "ATFT", output = "AUFU"