1

this.venuelist has type Venue

venuelist:Venue[] = [];

Type Venue has the property neighborhood on it.

I have the following for loop

for(let venue in this.venuelist){
      let remove = false;
      if(this.filters.neighborhood != ''){
        if(venue.neighborhood != this.filters.neighborhood){
          remove = true;
        }
      }
    }

calling venue.neighborhood called in the second `if statement` is not working

the error is: Property 'neighborhood' does not exist on type 'string.

for why? Why must it do this. Why can't it play nice? How do I make it place nice?

2 Answers 2

1
for(let venue in this.venuelist){}

for...in doesn't iterate over the array items, it iterates over the keys of the object passed in. You should use for...of

Sign up to request clarification or add additional context in comments.

Comments

0

for(let venue in this.venuelist){
      let remove = false;
      if(this.filters.neighborhood != ''){
        if(this.venuelist[venue].neighborhood != this.filters.neighborhood){
          remove = true;
        }
      }
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.