Mark As Completed Discussion

Are you sure you're getting this? Click the correct answer from the options.

What is the printed on the console for the following code?

JAVASCRIPT
1function compare_num(a, b){
2    if (a > b){
3        console.log("a is greater than b")
4        return a
5    }
6    else if (a == b){
7        console.log("a is equal to b")
8        return a
9    }
10    else{
11        console.log("a is less than b")
12        return b
13    }
14}
15
16var result = compare_num(4, 2)
17console.log(result)

Click the option that best answers the question.

  • 'a is greater than b', 2
  • 'a is less than b', 2
  • 'a is greater than b', 4
  • 'a is equal to b', 4