Skip to content

Instantly share code, notes, and snippets.

@klockey
Last active April 12, 2017 19:19
Show Gist options
  • Save klockey/31cdc051dfb6f28e7224fe4e0ebcb0f6 to your computer and use it in GitHub Desktop.
Save klockey/31cdc051dfb6f28e7224fe4e0ebcb0f6 to your computer and use it in GitHub Desktop.
katas for homework
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