Davidddd - 10 months ago 32

Javascript Question

so I am trying to create a function with two parameters. This function will be passed with two numbers as arguments. calculate the sum of the parameters. If the sum is less than or equal to 25, the function should return true. If not it should return false.

I know I must use a if and else loop to check the parameters (or a ternary which we have not covered yet.) This is what I have gotten so far. Please tell me if I am on the right track or completely wrong.

`function sum(augment1,augment2){`

var num= augment1 + augment2;

return num;

}

var a=sum(10,30)

console.log(a);

if (num > 25){

return true

}

else{

return false;

}

Answer Source

Your conditions should be inside your function right? So if sum is less than or equal to 25 true is return else false is. Can you try following?

```
function sum(augment1,augment2){
var num= augment1 + augment2;
if (num <= 25){
return true
}
else{
return false;
}
}
var a=sum(10,30)
console.log(a); //should be false
```