Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!