-
-
Save TexRx/6939990 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
// DISCLAIMER: This is not necessarily good code. It’s just code that I wrote | |
// as quickly as possible to do each task. | |
// 1 | |
return 2*i; | |
// 2 | |
return !(i%2); | |
// 3 | |
return (i.match(/\.(.+)$/) || [,false])[1]; | |
// 4 | |
var l = ''; | |
for (var n=0; n<i.length; n++) { | |
if (typeof i[n] == 'string' && i[n].length > l.length) { | |
l = i[n]; | |
} | |
} | |
return l; | |
// 5 | |
function arraySum(a) { | |
var sum = 0; | |
for (var i=0; i<a.length; i++) { | |
var n = a[i]; | |
if (n === +n) { | |
sum += n; | |
} | |
else if (Array.isArray(n)) { | |
sum += arraySum(n); | |
} | |
} | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment