Assignment with Returned Value

Tell us what’s happening:

Your code so far


// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line

console.log(processArg(7));
processArg = 2;
processed = processArg(num);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value

Be careful when assigning values ( = );

Let’s read your program step by step:

console.log(processArg(7));

This works, and log into console 2 since it calls the function passing 7 as value.

In the next line however

processArg = 2;

You are telling your program that now processArg is not a function anymore, is now the number 2.

processed = processArg(num);

In the final line you are trying to use processArg as a function, but it won’t work since now it’s the number 2, as you instructed your program in the line above.

Hope this help shed some light :smile: