Last active
February 11, 2020 23:32
-
-
Save destinmoulton/a4f05918e1ef81a2dbedfd052a84c115 to your computer and use it in GitHub Desktop.
JS JavaScript
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
| /** | |
| * This is a function. | |
| * | |
| * @param {string} n - A string param | |
| * @return {string} A good string | |
| * | |
| * @example | |
| * | |
| * foo('hello') | |
| */ | |
| function foo(n) { return n } | |
| /** | |
| * Return a Promise | |
| * | |
| * @returns {Promise} | |
| * @resolve {string} Description | |
| * @reject {Error} | |
| */ | |
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
| /** | |
| * From MDN | |
| * URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random | |
| */ | |
| /** | |
| * Generate a random arbitrary number | |
| * that is not less than min (inclusive) | |
| * and is less than max(exclusive). | |
| * | |
| * @param int min | |
| * @param int max | |
| */ | |
| function getRandomArbitrary(min, max){ | |
| return Math.random() * (max - min) + min; | |
| } | |
| /** | |
| * Generate a random integer between and | |
| * including min and max. | |
| * | |
| * @param int min | |
| * @param int max | |
| */ | |
| function getRandomIntInclusive(min, max) { | |
| min = Math.ceil(min); | |
| max = Math.floor(max); | |
| return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment