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;
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.