Quarter or Tier ? Both


#1

There's a problem in this exercise !

You can go to next one if the console display "The statement is true", so you can make it by any way.
This function is supposed to verified if the number is a quarter.
The function we maid verified if the result of the quarter is divided by 3.
So it works with (12)
because: 12 / 4 = 3 and 3 % 3 = 0

This would be more meaningful as for me:

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

if (quart(4)*4 % 4 === 0 ) {
 	console.log("The statement is true");
} else {
	console.log("The statement is false");
}

8. Functions, Return and If / Else
#2

The above makes no sense at all and does not follow the simple instructions given. I don't get your point.


#3

OK, I'm really sorry I misunderstood...

My first idea was to verified if the quarter return a number divisible by 4.
(to verified if the quarter function return a real quarter)
I couldn't understand why you want me to check if the quarter is divisible by 3.
It's quiet hard to understand that we have to put a number that is divisible by 4 then by 3, when we just begin with JavaScript and arithmetic.

I'd like to be helpful but I was just out of subject.


#4

Then the idea would be to solve this question before giving advice on the solution. What help is that? We cannot speak for the author of this now very old exercise, but it would appear they were making the problem more challenging, possibly drawing on any math knowledge the learner may possess.

This is a problem relating to Least Common Multiple type problems in grade school mathematics. If one is familiar with the concept, one will reason out the solution in minutes.

"What number is divisible by both 4 and by 3?" Their LCM, 12 or any multiple of it, including zero. 0 % 3 is 0.

Programming relates to practical concerns, so always think in that direction. It's not magic, but logic, and a little arithmetic.


#5

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