Let's implement a simple function that takes two parameters " width" and " height" of a picture, and suppose to return true if our picture is a landscape and return false if it isn't.
we can handle it with this simple code
if(width > height) return true
return false
but we can write it in a better way if we use a conditional operator
return width > height ? true : false
we can improve it even further more like this
return width > height
Top comments (0)