Created
October 2, 2017 03:42
-
-
Save VitorLuizC/16edb4af3ee7b1fe7a5b21a8f32b8f73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const divide = (...values) => { | |
divide.before(...values) | |
try { | |
const result = values.reduce((a, b) => a / b, 0) | |
divide.success(result, ...values) | |
divide.after(...values) | |
return result | |
} catch (error) { | |
divide.failure(error, ...values) | |
divide.after(...values) | |
} | |
} | |
divide.before = (...values) => console.log('Before: ' + values.join(' % ')) | |
divide.success = (result, ...values) => console.log('Success: ' + values.join(' % ') + ' = ' + result) | |
divide.failure = (error, ...values) => console.log('Failure: ' + values.join(' % ') + ' = ' + error.message) | |
divide.after = (...values) => console.log('After: ' + values.join(' % ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment