Code is True when “return (number)/4;” and False when “return number/4;”.
Why? It is should be True when “return number/4;” .
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”);
}
No, that makes no difference. Something is wrong about that observation, perhaps you changed something else as well.
No changes except this
var quarter = function(number) {
return (number)/4;
};
And this is meaning of syntax.
Exercise is ok when number between parenthesis.
Sure
// 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”);
}
// 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”);
}
Did you also run them and test whether they produce different output?
They do not
They produce “The statement is true”, both.
Wasn’t the problem that they didn’t?
Sorry, i mean this “return quater(number)/4”.
ionatan
February 4, 2017, 9:31pm
10
If you divide a quarter by four then you have one sixteenth. Why would 1/16 % 3 be true?
It’s an infinite loop too - quarter calling itself each time it is called
ionatan
February 4, 2017, 9:40pm
12
Why what? No mind reading here
Interpreter telling me “quater is not defined” and let me through to next exercise.
So quater can be not defined?
ionatan
February 4, 2017, 9:45pm
14
Why wouldn’t it be possible to define quater?
var quater = 5;
It probably passes because the exercise’s author didn’t anticipate the situation you created. That’s somewhat common actually (but you should be verifying your own code either way, it’s important to see the effects of what you write)
Agree, i’m testing my code several times with possible options. But time to time found something unusual here.
Anyway thx for spent time.
ionatan
February 4, 2017, 9:51pm
16
If you defined a function, and quater isn’t defined, then the function must surely have a different name?