js check which number is larger

Solutions on MaxInterview for js check which number is larger by the best coders in the world

showing results for - "js check which number is larger"
Leon
07 Feb 2020
1//Which number is larger
2function whichIsLarger(num1 , num2){
3	return num1 > num2 ? 'num1': num1 < num2 ? 'num2' : 'neither';
4}
5
6console.log(whichIsLarger(10, 8)); //num1
7console.log(whichIsLarger(11, 11));//neither
8console.log(whichIsLarger(-1, 5)); //num2