I have two integers (integerOne
and integerTwo
) and I need to write a JavaScript program that outputs the larger one in the console.
The integers are defined like so:
let integerOne = 8;
let integerTwo = 10;
And I’m expecting 10 to be printed as the output. How do I do this?
3
Answers
We can use the > operator to return a boolean, and depending on the boolean we can use the ternary operator to print the output.
you can use a simple comparison statement to compare values. for example:
The above example will print 10 on your console.
Use
Math.max
: