
Mathew Yangang
1,427 Pointsjust curious, what's wrong with this code?
Got a couple of errors, not sure what i'm doing wrong
a = 1;
b = 2;
function max(1,2){
if (b>a)
return (2);
}
2 Answers

Jon Tang
5,093 PointsYour functions have to have parameters. Like a and b instead of 1 and 2.
function max (a , b) {
}
then you state what that function does.
function max (a , b) {
//Your code here
};
which is...
function max (a , b) {
if (b > a ) {
return(2);
};
};
then use console.log to return your results
function max (a , b) {
if (b > a ) {
return(2);
};
};
console.log(max(1, 2));
this should return 2 in the web console

Mathew Yangang
1,427 PointsThanks Jon.

Mathew Yangang
1,427 PointsI did that, but the function max is not working