Last active
December 24, 2015 21:39
-
-
Save abhishekdev/6866955 to your computer and use it in GitHub Desktop.
Revisions
-
abhishekdev renamed this gist
Oct 7, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
abhishekdev created this gist
Oct 7, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ /** * Solutions to questions at {@link http://toys.usvsth3m.com/javascript-under-pressure/ } */ // Ans 1 function doubleInteger(i){ return i*2; } // Ans 2 function isNumberEven(i){ return i%2 == 0; } // Ans 3 function getFileExtension(i){ var rawExt = i.match(/\.+[a-zA-Z0-9]+/), ext = false; if(rawExt && rawExt.length){ ext = rawExt[0].substring(1); } return ext; } // Ans 4 function longestString(i){ for(var x = i.length - 1; x>=0; --x){ if(typeof i[x] != 'string'){ i[x] = ""; } } i.sort(function(a,b){ return b.length - a.length; }); return i[0]; } // Ans 5 function arraySum(i){ var sum=0, x = i.length - 1, val; for(; x>=0; --x){ val = i[x]; switch(typeof val){ case "number" : sum += val; break; case "object" : sum += arraySum(val); break; } } return sum; }