Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


What is wrong with this function?

Define a function called quarter which has a parameter called number. This function returns a value equal to one quarter of the parameter. (i.e. number / 4;) Call the function inside the if statement's condition (and put in a parameter value!) such that "The statement is true" is printed to the console. ?

var quarter = function (number) { console.log(number/4) }

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

2 Answers

Michael Hulet
Michael Hulet
47,842 Points

First of all, you're declaring the function wrong. It's declared as function name(parameters){//Code}. After that, I don't think you're supposed to call console.log() inside of the function, but just have the function return the proper value, instead. Tell me if this works:

function quarter(number){
  return number/4;
if(quarter(8) % 2 === 0){
  console.log("The statement is true");
  console.log("The statement is false");

yes that worked. Thank you very much.