title: VueJS - How to check an array on matching values?
body: <p>I'm working on a <code>couponcode</code> VueJS app, in which I want to check an array with different <code>discountcodes</code> on matching values. Below I have an array with two <code>discountcodes</code>. If the button is clicked, I want to check the array for any matches. I am not sure what would be the best solution for this..</p>
  
  <pre><code>&lt;template&gt;
      &lt;div class="container"&gt;
  
          &lt;input placeholder='type discount' v-model="discountInput"&gt;
          &lt;button @click="checkDiscount"&gt;check for discount&lt;/button&gt;
  
          &lt;span class="alert" v-if="discountValid"&gt;
              Code juist
          &lt;/span&gt;
  
          &lt;span class="alert" v-if="discountInvalid"&gt;
              Code onjuist
          &lt;/span&gt;
  
      &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  
    export default {
  
      props: {
  
      },
  
      data: () =&gt; {
          return {
              discountInput: '',
              discountValid: false,
              discountInvalid: false,
              discountCodes: [
                  { code: 'discount-code-1', message: '10% discount' },
                  { code: 'discount-code-2', message: '5 dollar discount' }
              ]
  
          }
      },
      components: {
  
      },
      methods: {
  
          checkDiscount() {
              if (this.discountInput === this.discountCode) {
                  return true;
              } else {
                  return false;
              }
          }
  
      },
      watch: {
  
      }
  }
  &lt;/script&gt;
  </code></pre>