Qual função retorna o maior número?

Published by Jon Ingram in

Sua função receberá duas funções, f e g, que não aceitam nenhum parâmetro. Sua função deve chamá-las e retornar uma string que indique qual função retornou o maior número.

  • Se f retornar o maior número, retorne a string f.
  • Se g retornar o maior número, retorne a string g.
  • Se as funções retornarem o mesmo número, retorne a string neither.

Exemplos

whichIsLarger(() => 5, () => 10) ➞ "g"

whichIsLarger(() => 25,  () => 25) ➞ "neither"

whichIsLarger(() => 505050, () => 5050) ➞ "f"

Observações

Este exercício foi criado como uma introdução a funções de ordem superior (funções que usam outras funções para realizar seu trabalho).