I am working on a task to create a function called "tousVerts" which translates to "everythingGreen" in French. The goal of this function is to change the color of specific text on the page to green. This text is enclosed within either EM or A html tags. In order to access it, I am attempting to use document.getElementByTagName(). One of these tags needs to be passed as a parameter to the function for it to change the text color.
var tousVerts = function(elt) {
var elements = document.getElementsByTagName (elt);
elements[0].style.color = "green";
}
While it seems like a simple task, I am facing an issue where the function is not working as expected. It appears that I may need to utilize a local variable i to iterate through the array indices, but I am uncertain about how to proceed.