8/13 "Quarter function doesnt return -25 for -100"?


#1

I know the error seems pretty obvious but, am I missing something or just not looking at the right place? Any guidance would be helpful thanks!

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

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


#2

this was really confusing...

answer should be 0 to get the true statement.

// Define quarter here.
var quarter = function(number)
{
 return number / 4;   // defined at the left Instructions
}

if (quarter(0) % 3 === 0 )  // % is modulo, when value is equal to zero true statement will appear, 
                                     //if not false statement.
{
  console.log("The statement is true");
} 
else 
{
  console.log("The statement is false");
}

#3

Here is the code I used:

// 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");
}


#4

It should be able to take any number that is evenly divisible by 4.


#5

that's explain why i couldn't calculate the numbers... i think i still didn't understand the instruction to find the answer as 12...
well, thx @zeroclifawn
going to try again and re-study this section again..


#6

Oops. I said 4 but rather it has to be divisible by 3. The function is merely checking to see if the number you put in is divisible by 3. In my case I inserted 12. It returned True because 12 is divisible by 3.


#7

@aezqueda05

The issue with your code is where you have
"return 9/3;"

instead it should be:
"return number /4"

number in this case is referring to the input for the function:
"var quarter = function(number)"


#8

It will work for you :wink:

// 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");
}

#9

@zeroclifawn @methodslayer82614

Really helped out, thanks! Instructions can be rather confusing


#10

This is BS. That's exactly what I put; Howerver, I keep getting an error "Oops, try again.
Hmm, it looks like your quarter function doesn't return -25 for -100"

I guess adding the return line fixes the issue; It's still not clear that
return number / 4; needs to be called instead of, say console.log(number / 4);


#11

First of all why do you revive a 2 month old thread? If you have a question please open your own one providing the necessary information (your code + exercise name or number + error message).

Last but not least isn't that the default setting that doesn't need to be changed anyway?


#12

Why I revive a 2 month old topic.

Because it's easier to have in a single point of reference all the information regarding a specific challenge that is unclear. It sucks to have jumping around several topics that all talk about the same challenge.

Alternative

Instead of creating a var, as in the above examples, for me it worked by simply creating a function:

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


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

#13

3 month old the last person who revived it did this after 2 month so its practically dead for 5 months...

It is rather an exercise than a challenge and I've no idea what information and reference points you talk about so this one failed at least for me.

Flag them and suggest a better title, we'll fix them and maybe the next one has more luck. Otherwise ask your own question and link to an existing one if necessary.

This has nothing to do with the exercise or the other posts here. For more information about this you might have a look at this:


#14

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