How can I iterate through an array of field handles for an entry? Background:

One of my templates has up to 6 fields that should each go into the same markup. Here's an example with a courseDesign field:

{% if entry.courseDesign|length %}
  &lt;section class="col-xl mb-3"&gt;
    &lt;h2 id="courseDesign"&gt;Course Design&lt;/h2&gt;
    {{ entry.courseDesign }}
  &lt;/section&gt;
{% endif %}


This worked fine when I wrote each section out like this. However, once I also added a table of contents/nav, I decided to refactor. 

I now have a courseFields array, and I'm adding each field to it if it exists:

{% set courseFields = {} %}
{% if entry.courseDesign %}
  {% set courseFields = courseFields|merge({ "courseDesign": { handle: "courseDesign", title: "Course Design" } }) %}
{% endif %}


My navigation macro works perfectly, because it's only interacting with the objects in the courseFields array.

My problem: 

I can't figure out how to iterate through my fields and get the actual content from them using a macro. 

If I use {{ entry.handle }} in my macro, even when handle is a valid field handle, I get the runtime error Variable "entry" does not exist. 

I also tried: 

{% set courseField = "entry." ~handle %}
{{ courseField }}


but that produces a string: "entry.courseDesign". 

How do I access entry from my macro? Should I be going about this a different way?
I figured it out! I ditched the macro and just included the following in my template:

{% for field in courseFields %}

  &lt;section class="col-xl mb-3"&gt;
    &lt;h2 id="{{ field.handle }}"&gt;{{ field.title }}&lt;/h2&gt;
    {{ entry[field.handle] }}
  &lt;/section&gt;

{% endfor %}