Skip to content

Instantly share code, notes, and snippets.

@DannyMichaels
Forked from kosalvann/max.js
Created September 13, 2020 23:15
Show Gist options
  • Save DannyMichaels/217943b080c0d1e909ad46f0c2c3417d to your computer and use it in GitHub Desktop.
Save DannyMichaels/217943b080c0d1e909ad46f0c2c3417d 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment