append_elements: using Array.prototype.forEach to loop over elements object