I have started to learn to use JavaScript, I have no experience in this kind of languages. Basically what I want to do is replace some characters of the names of the elements, for example, the following program gives me the 4 fruits, at the time of printing I would like to replace the "a" por "4"
and the "g" por "j"
.
Is this possible in JavaScript?
var fruits, text, fLen, i;
fruits = ["Banana", "Orange", "Apple", "Mango"];
fLen = fruits.length;
text = "<ul>";
for (i = 0; i < fLen; i++) {
text += "<li>" + fruits[i] + "</li>";
}
text += "</ul>";
document.getElementById("demo").innerHTML = text;
<p>The best way to loop through an array is using a standard for loop:</p>
<p id="demo"></p>