Couldn't find an answer on here that worked, so I assume I just missed it. I also find that Googling solutions make things worse for me.
I tend to find that I overthink the solutions in Javascript, and this obviously leads to an inability to solve the solutions.
You also don't necessarily need the return true
, but I added it anyways.
Just remember that logically ordered simplicity is key.
var quarter = function(number) {
var number = n / 4;
var n = 48;
if (quarter(number) % 3 === 0 ) {
console.log("The statement is true");
return true;
} else {
console.log("The statement is false");
}
}
I hope that works for you.
I'll use my lack of JavaScript skill and knowledge to explain this to beginners like myself, and you. And anybody who has an extreme knowledge of JavaScript will probably disagree, but it's also why most programming employers will take a Communication major over a programmer anyday:
- Define a function named quarter, meaning you are defining a function-- quarter -- but you must first define what quarter-- var.
var quarter = function(number)
- The function returns a value that equals to
n / 4
The function is being defined asquarter(number)
The value is number.
You then introduce a new var that defines the value with number = n / 4
To return true and begin your if statement,
function(number or n)
is now quarter, the function you're defining.
The basis of providing a correct equation relies on it returning true in the form of
console.log("The statement is true!")
You do this by then defining n with a number that will be divided 4, and then that number being able to be divided by 3 with no remainder.Since number
has been defined as
n / 4
, With n being defined as 48 in this example, both: quarter(number)
and quarter(n)
will work for the if / else statement.
To bring a remainder of 0 after dividing by 3, use % 3 === 0
.
- So
if (quarter(number) % === 3 {
is now the defined function quarter. number
is a parameter, and you assign the value of the parameter with variables,var number = n / 4
and
var n = 48
.
On that note, as I'm typing this, this would, in theory, also work and being shorter:
var quarter = function(number) {
if (quarter(48) % 3 === 0) {
console.log("This statement is true!");
return number = number / 4;
} else {
console.log("This statement is false.");
};
};