Lesson 8 return, if/else, function


#1

// Define quarter here.
var quarter = function(number) {
return number / 4;
};

if (quarter(12) % 3 === 0 ) {
console.log("The statement is true");
} else {
console.log("The statement is false");
}

I have the right function I just don't understand its purpose? Why do I need return here and do I dived the number by 4 and then do the modulo thing?


#2

The purpose of a function is to transform input into some output

In your case, your function transforms a number to another number that is a quarter of the input
To do that it needs to divide by 4


#3

oh okay thank you :slight_smile:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.