Guest User

Untitled

a guest
Oct 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. // Function with Math
  2. function diff(num1, num2) {
  3. return Math.abs(num1 - num2);
  4. }
  5.  
  6. // Function with ternary operator
  7. function diff(num1, num2) {
  8. return (num1 > num2) ? num1-num2 : num2-num1;
  9. }
  10.  
  11. // Function with regular if
  12. function diff(num1, num2) {
  13. if (num1 > num2) {
  14. return num1-num2
  15. } else {
  16. return num2-num1
  17. }
  18. }
Add Comment
Please, Sign In to add comment