Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
Two objects javascript. I am bit confused

I'm a bit confused with JavaScript's objects. I want the following :

function to accept as the first parameter the object person, and as the second parameter the name field. It will modify the person object, in which the field (property) name of the object person to receive the value that passed as the second parameter. The function will not return anything, it will modifies the object directly.

Take the following piece of code:

let person = {
  name: "name",
};

let name = {
  name: "name_02",
};

let b = person === name;

function setName(person, name) {}
console.log(b);

I am sure that my code is miserable because I am a beginner, please help me with clarifications and your understanding.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your not a million miles away. The question is asking you to create a function that can be called on a person object, and set it's name using the second parameter.

So you created the function with the 2 params, but just have not done anything with it yet.

Not sure what your trying to do with the comparison part, as that's not in the question anyway.

Your probably after something like ->

let person = {
  name: "name",
};

function setName(person, name) {
  person.name = name;
}

console.log(person);
setName(person, 'Bob');
console.log(person);

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda