# Function Declarations

#1

I am at the Learn Javascript Functions, 7. Function Declarations exercise

I am stuck on the second exercise of the lesson

Inside the function, using an if/else statement, create the following logic:

If numberOne is greater than numberTwo, return true.

Otherwise, return false.

I am unable to complete this step so I can use some help.

The following code is the code I made, based on the hint given in the lesson.

function isGreaterThan (numberOne, numberTwo){
if (numberOne > numberTwo)
return true;
} else {
return false;
}

Any help is appreciated.

#2

The opening brace is missing from the end of that line.

#3

Thanks for the assistance. Was able to get the exercise completed. Have one other question though.

So my final code ended up like this.

function isGreaterThan(numberOne, numberTwo){
if (numberOne > numberTwo){
return true;
}else{
return false;}
}

console.log(isGreaterThan(7, 5));

As you can see, my block opens with 2 { braces and ends with 2 } braces. However the hint doesnâ€™t indicate that another opening brace needs to follow the first opening brace and it ends with one curly brace, copy pasted below for reference.

if (some condition) {
return true;
} else {
return false;
}

Going by this hint, the code I first used got a failure message. Is the code I used some alternative way of doing the function or is the hint given incorrect/misleading/unclear? I tried other versions of the code by altering the {} braces, but only my version worked.

#4
``````function funcName (param) {
// code inside the block
}
``````
``````  if (condition) {
// action
} else {
// default
}
``````

Put the two togetherâ€¦

``````function funcName (param) {
if (condition) {
// action
} else {
// default
}
}
``````

Notice that the `if` and its blocks are nested inside the function block? Both need their own containment.

#5

Thanks for explaining and clarifying.

#6

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