Last active
April 12, 2017 19:19
-
-
Save klockey/31cdc051dfb6f28e7224fe4e0ebcb0f6 to your computer and use it in GitHub Desktop.
katas for homework
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
https://www.codewars.com/users/krock/completed_solutions | |
function divisors(integer) { | |
z = [] | |
i = 2 | |
while ((i <= integer - 1)){ | |
if (integer % i === 0){ | |
z.push( i) | |
} | |
i++ | |
} | |
return z.length === 0 ? `${integer} is prime` : z | |
} | |
function invert(a) { | |
roots = a.map(function (n) { | |
if (n !== 0) { return -n } | |
if (n === 0) { return 0 } | |
}) | |
if (a.length === 0){ | |
return a | |
} else { | |
return roots | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment