I need to insert a class attribute of "odd" or "even" for each paragraph in the HTML displaying using the modulo and ternary operator. I extracted the paragraph element, but I am unsure of how to insert the class and word the code within the ternary operator. I know my code is pretty terrible, but any tips or suggestions would be wonderful.
function oddEven()
{
var parArray= document.getElementsByTagName("p");
for(var i=0; i<parArray.length; i++)
{
(parArray % 2== 0)? parArray=="even" : parArray=="odd";
}
//end of oddEven()
}