São iguais?
Crie uma função que receba dois objetos e uma chave.
- Retorne
truese ambos os objetos contiverem a chave com valores iguais. - Retorne
"One's empty"se exatamente um dos objetos contiver a chave. - Retorne
"Not the same"se os objetos contiverem valores diferentes ou se nenhum deles contiver a chave.
Exemplos
checkSame({ sky: "temple", horde: "orcs", people: 12, story: "fine", sun: "bright" }, { people: 12, sun: "star", book: "bad" }, "horde") // "One's empty"
checkSame({ sky: "temple", horde: "orcs", people: 12, story: "fine", sun: "bright" }, { people: 12, sun: "star", book: "bad" }, "people") // true
checkSame({ sky: "temple", horde: "orcs", people: 12, story: "fine", sun: "bright" }, { people: 12, sun: "star", book: "bad" }, "sun") // "Not the same"Observações
- A ordem das chaves é irrelevante.
- Uma chave com um valor
nullouundefinedainda conta como presente.