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

179
Visualizações
can't understand assignment with return value in javascript

I'm watching a video by freecodebootcamp on youtube called 'Learn JavaScript - Full Course for Beginners' and when they explain 'assignment with returned value' at the 1hour 5minute mark the person has set a value to 'change(num)' then outside of the function sets a value of 10 to it and I just don't seem to understand why he has added the 10 when he gave it a value already form the function.

image of code I am talking about

var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

console.log(changed);

(my thought process below)

so you see where he has already given change a value of the outcome of 5/3 which is 1.6

so change = 1.6

then he has changed = changed

which in my mind means changed also = 1.6

but then he adds the (10)

why has he added a value to change if it already had a value of 1.6

what does the 10 do

has it changed the value of 1.6 to 10

I don't understand it and he just skips onto the next thing like it has been explained.

why not just set var changed = 10;

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

0

1.6 Does not happen. Since the num input is 10, the code will run once console.log(changed) is stated and it will begin the math. since num is 10 it will be (10 + 5) / 3 which will return 5.

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