Pergunta de entrevista da empresa Tinder

How can you solve this javascript class problem