Quarter()


#1

this question is a little tricky..i need help..thank you
lesson 8

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


Functions & If/Else - sleepCheck - HELP, please!
#2

Hey, I've also had trouble with thise one.

What I've had done was the following:
- Create Var function code. (Example: from lesson 7 the timestwo function, just copy and paste it and rename the timestwo to quarter.)

Return number / 4

  • Next on line 7 make sure to put in quarter() number 3 or 4 or whatever you like. The important part is the === if you delete 2 of the = then the lesson is complete, but it doesnt give the right print. IT gives error, but still complets the lesson.

#3

This is the code i've used:

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

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


#4

I think there is a little bug as to why i could pass that lesson.

How ever I've tried to come out with a solution to the code and this is the correct code:

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


#5

Since the number inside the parentheses of "quarter" is supposed to be a be a value, you must NOT put the value as a string. So, take out those parentheses.

Yes, I had trouble with this too. I had my dad help me with this one, and he said that it should work with 11, 12, 13, 14, if you put as that, but it didn't work with JS. We went with the conclusion that it's because JS is an interpreter.

ANYWAYS:

For the value of quarter, you must make it work as

number % 3 === 0 // Note the equal sign

And the number has to be able to be returned by 4. So this is what I did:

3 * 4 !

Yeah, let's go with normal multiplication now. :smiley:
Since 3*4 equals 12, and it could be divisible by 4 and using modulo on it with 3 equals 0, I used the value as 12 in the value of quarter.

P.S. 12, 24, 36, all multiples work as the values of quarter.


#6

I don't recall modulo being introduced yet at this point, which may be part of the problem. If you don't know that "number % 3 === 0" means that there should be no remainder when the number is divided by 3, this task seems more complicated than it should be.


#7

they actually introduced modulo a long ■■■ time ago that's not the problem the problem Is that we are still learning