How do I write the function to quarter in lesson 8


// Define quarter here.

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

  1. Define a function called quarter which has a parameter called number.
  2. This function returns a value equal to one quarter of the parameter. (i.e. number / 4;)

var quarter //your variable

= function(number) //your functio and its parameter

return number/4 //your return statement that was given to you

So basically it should look something like this:

var quarter = function(number) { //you need { and } as well!
return number/4


I don't know how to do lesson 8, function, returns and if/else...Can somebody write me whole exam? Thank you


@bibleman13 this is my new code but it comes out as false and to pass it needs to be true

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

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

please help :confused:


Yeah I had the same exact problem when I was going through this lesson a couple of months ago! It was tricky but basically in your if statement specifically your quarter statement you need a number that when divisible by 3 gives you no remainder. So for example 72 divided by 3 gives you 24 with no remainder. That should be the only problem you have everything else looks correct.

And when I say if statement with quarter function I do mean here: if (quarter() % 3 === 0) {
Specifically, ter() % in the parentheses :smiley:


I believe this should lead you through everything you need to know for this lesson @sakalic


Thanks for the help @bibleman13



No problem! Happy to help! Happy coding! :smiley:


yeah, thank you @bibleman13


No problem! Hope the other lessons are less confusing for you! :smiley:


now I'm just speeding through the functions


Well thats great! Sometimes, and I find this with many things, you struggle on something for a while and then once you get it its like a light bulb comes on and poof you breeze through it all and you wonder how you ever got stuck in the first place haha


so this lesson confuses me :slight_smile: (12.Function & if / else) I think I did it right but there's some mistake???


Ah. It would seem you are missing an ! right after eye in your return Get some more shut eye. So basically this

return "Get some more shut eye";

needs to be this

return "Get some more shut eye!";


oh, what a stupid mistake ! :slight_smile: thank you


No problem! And believe me its too easy to miss a punctuation xD I have done that wayyy to many times haha


I have too. and most of those times it came out to me not figuring out the problem for like a week
@bibleman13 @sakalic


I can help you in understanding with a different example. Please refer the example created by me.

var qualification = function(number){
var present = prompt("What is the present year?");
return present - number;
var dob = prompt("Enter your birth year");

if (qualification(dob) >= 18 ) {
console.log("Wow!! You are a Major");
} else {
console.log("Oops.. You are still a Minor");

Hope this will help you understand previous lessons also little better.
In this i am asking user to enter his Date of Birth's year first.
Then i am asking the user to enter the current year.
So after calculations if user is <18 years old it will say he is a Minor, else if he is >=18 years it will say he is Major.


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