Modo entrevista. Cronômetro de 3 min, sem dicas e sem autocompletar
JSON there and back
FácilJSON and data3 min
Write a function jsonRoundTrip(user). It turns the object user into a JSON string and then parses that string back into a new object. Return { json, copy } with the string and the object made from it.
Exemplos
jsonRoundTrip({ name: 'John', age: 35 })Retorna { json: '{"name":"John","age":35}', copy: { name: 'John', age: 35 } }
Carregando o editor...
- Entrada
jsonRoundTrip({ name: 'John', age: 35 })Esperado{ json: '{"name":"John","age":35}', copy: { name: 'John', age: 35 } } - copy equals user, but it is a different object
Os testes ocultos rodam no envio