Change getElementsAttribute to use Array.map()