freeCodeCamp Challenge Guide: Assignment with a Returned Value

Assignment with a Returned Value


Hints

Hint 1

Functions act as placeholders for the data they output. Basically, you can assign the output of a function to a variable, just like any normal data.


Solutions

Solution 1 (Click to Show/Hide)
processed = processArg(7); // Equal to 2
5 Likes

Solution is very simple of this question:
// 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

processed = processArg(7);

11 Likes

You need to be smart: And follow this formula in assigning a number for **processArg** function (X + 3) / 5 = 2

2 Likes

Hey fellow campers.Everyone is unique when it comes to learning.Use whichever method you find fit to drive the logic home.This is how I did it:

// Example
function minusSeven(num) {
return num - 7;
}

// Only change code below this line

function timesFive(num) {
return num * 5;
}

var answer = timesFive(5);

1 Like

Sorry that was for previous challenge.

Here we go:

// 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

processed = processArg(7);

6 Likes