Skip to content

Instantly share code, notes, and snippets.

@kosalvann
Last active September 17, 2022 17:42
Show Gist options
  • Save kosalvann/c62bc333cad7a0bfc209 to your computer and use it in GitHub Desktop.
Save kosalvann/c62bc333cad7a0bfc209 to your computer and use it in GitHub Desktop.
Define a function max() that takes two numbers as arguments and returns the largest of them. Use the if-then-else construct available in Javascript.
// Define a function max() that takes two numbers as
// arguments and returns the largest of them. Use the
// if-then-else construct available in Javascript.
// https://jsfiddle.net/ryjtyomv/
function max(firstNum, secondNum){
if (firstNum > secondNum) {
console.log(firstNum + " is larger than " + secondNum);
} else {
console.log(firstNum + " is less than " + secondNum);
}
return;
}
// Lets set two numbers
max(142,234);
@Sidcodes18
Copy link

Thanks man for the idea. I just caught it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment