Build your intuition. Click the correct answer from the options.
What is the output for the following code?
1function compareNum(a, b) {
2 if (a > b) {
3 console.log("a is greater than b");
4 return a;
5 } else if (a === b) {
6 console.log("a is equal to b");
7 return a;
8 } else {
9 console.log("a is less than b");
10 return b;
11 }
12}
13let result = compareNum(4, 2);
14console.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