I am trying to get Javascript to read and write a paragraph based on content elsewhere on the page (specifically the names of items in a cart summary). The problem is that I can't get Javascript to write them correctly.
I need the being written paragraph to be "Order Includes: Product 1, Product 2, etc." but instead it is returning "Order Includes: [object HTMLParagraphElement], [object HTMLParagraphElement], etc."
<!-- Cart Summary -->
<p class="cartitems" id="Quantity">Product 1</p>
<p class="cartitems" id="Quantity">Product 2</p>
<!-- Paragraph to be written -->
<p id="printItems"></p>
<script>
var prods = document.getElementsByClassName("cartitems");
var items = Array.from(prods);
document.getElementById("printItems") = "Order Includes: " +
items;
</script>
I've tried using
var prods = document.getElementsByClassName("cartitems").innerHTML;
and
document.getElementById("printItems").innerHTML = "Order Includes: " +
items;
But both return undefined.