Tinder interview question

How can you solve this javascript class problem