title: Changing object variable address in function
body: <p>I've got very basic function</p>
  
  <pre><code>  defineSpeciality() {
          for (var i=0; i&lt;this.readyOffer.speciality.length; i++) {
            output = output  + this.readyOffer.speciality[i].name + ', '
          }
        return output
    },
  </code></pre>
  
  <p>I want to be able to pass the parameter inside my function and change <code>this.readyOffer.speciality.length</code> into for example <code>this.readyOffer.experience.length</code></p>
  
  <p>so my function should be something like this:</p>
  
  <pre><code>  defineSpeciality(parameter) {
          for (var i=0; i&lt;this.readyOffer.[parameter].length; i++) {
            output = output  + this.readyOffer.[parameter][i].name + ', '
          }
        return output
    },
  </code></pre>
  
  <p>but this of course does not work. How to do it?</p>