title: How to build a multiple IF conditional in Mule 4 and DW 2.0?
body: <p>I need to create a function with conditions like this pseudo-code:</p>
  
  <pre><code>var consent = []
  
  function buildConsent() {
     if (condition1) {
         consent += values1
     }
  
     if (condition2) {
         consent += values2
     }
  
     if (condition3) {
         consent += values3
     }
  }
  </code></pre>
  
  <p>This is how I am doing it on Mule4 and DW 2.0:</p>
  
  <pre><code>%dw 2.0
  var consent = []
  var factIntake = vars.facts
  
  fun buildConsent() =
      if (factIntake.miscFactItems[?($.value1 == true)] != null) {
          consent + {
              "Consent_Type": "some1",
              "Consent_Given_By": "some2"
          }
      }
  
      if (factIntake.miscFactItems[?($.value2 == true)] != null) {
          consent + {
              "Consent_Type": "some3",
              "Consent_Given_By": "some4"
          }
      }
  
  output application/json
  --
  {
      "Consent_Data": buildConsent()
  }
  </code></pre>
  
  <p>But I am getting the following error from the IDE (AnypointStudio 7):</p>
  
  <blockquote>
    <p>Invalid input '+', expected Namespace or
    Attribute&lt;'@('(Name:Value)+')'> (line 11, column 11):</p>
  </blockquote>
  
  <p>Where line 11, column 11 is the first appearance of <code>consent +</code>. If I try to debug the project all I got in the console is:</p>
  
  <blockquote>
    <p>Message               : Error while parsing script: %dw 2.0</p>
  </blockquote>
  
  <p>Here is an example of input/output for you to better understand what I am trying to achieve:</p>
  
  <pre><code>// Input
  {
      "miscFactItems": [{
              "factId": "designeeFirstName",
              "factValue": "test test",
              "factValueType": "System.String"
          }, {
              "factId": "designeeLastName",
              "factValue": "test test",
              "factValueType": "System.String"
          },{
              "factId": "value1",
              "factValue": true,
              "factValueType": "System.Boolean"
          }, {
              "factId": "value2",
              "factValue": true,
              "factValueType": "System.Boolean"
          }, {
              "factId": "value3",
              "factValue": true,
              "factValueType": "System.Boolean"
          }
      ]
  }
  
  // Output
  consent = [{
               "Consent_Type": "type1",
               "Consent_Given_By": miscFactItems.designeeFirstName
           }, {
               "Consent_Type": "type2",
               "Consent_Given_By": miscFactItems.designeeFirstName
           }, {
               "Consent_Type": "type3",
               "Consent_Given_By": miscFactItems.designeeFirstName
           }
  ]
  </code></pre>
  
  <p>What I am missing here? How do I add the three conditions to my function and append the values to the <code>consent</code> var?</p>