This file contains 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
function revrot(str, sz) { | |
/** | |
* If string (str), size (sz) or size is greater than string's | |
* length, return empty string. | |
*/ | |
if (sz === 0 || str.length === 0 || sz > str.length) { | |
return '' | |
} |
This file contains 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
/* | |
Implementation of The Luhn Algorithm (https://en.wikipedia.org/wiki/Luhn_algorithm) | |
*/ | |
function validate(n) { | |
/** | |
* Check if the given number is of valid type | |
*/ | |
if (!n || typeof n !== 'number') { |
This file contains 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
// CoffeeScript | |
square = (x) -> x * x | |
cube = (x) -> square(x) * x | |
fill = (container, liquid = "coffee") -> | |
"Filling the #{container} with #{liquid}..." | |
// ES6 | |
let square = (x) => x*x | |
let cube = (x) => square(x)*x | |
let fill = (container, liquid = null) => `Filling the ${container} with ${liquid}...` |
NewerOlder