Why does this just not work out for me ?
<script type="text/javascript">
var gene="ATTAHATHHATTCGTA";
var i=0;
for (;i<gene.lenth;i++)
{
if(gene[i]=='H')
gene[i]='G';
}
</script>
I change it by use of replace as follows
<script type="text/javascript">
var gene="ATTAHATHHATTCGTA";
var i=0;
for (;i<gene.lenth;)
{
var pos=gene.replace("H","G");
i+=pos;
}
</script>
but I am still out of luck. Thank you for any help.
The
String.replacemethod is used much more simply:Simple as that.
However, this is not going to work on all browsers. To make it portable, you have to specify the first parameter as a regular expression, like this: