Blog

JavaScript – Date.prototype Extensions

Yesterday’s post made me want to extend the Date.prototype object a bit more. Therefore I came up with the following code: The above code defines the following prototypal functions: Date Adders Date.prototype.addYears() Date.prototype.addMonths() Date.prototype.addDays() Date.prototype.addHours() Date.prototype.addMinutes() Date.prototype.addSeconds() Date.prototype.addMilliseconds() Date Differs Date.prototype.diffYears() Date.prototype.diffMonths() Date.prototype.diffDays() Date.prototype.diffHours() Date.prototype.diffMinutes() Date.prototype.diffSeconds() Date.prototype.diffMilliseconds() Unlike the XDate Read more…

By Chris West, ago
Blog

POW Answer – Explain That SQL #1

To answer last week’s POW, the purpose of the SQL was to generate a random string of letters and numbers. I actually wrote two different JavaScript function that can produce the same results. The following is the slightly more straight-forward solution: The next version is a bit harder to follow Read more…

By Chris West, ago
Blog

POW – Explain That SQL #1

Someone asked me to quickly write them some code in any language that would accomplish a certain task. The following, which is in PostgreSQL, is the second solution that I came up with after doing the first one in my favorite language, JavaScript: The question is, what does this SELECT Read more…

By Chris West, ago
Blog

POW Answer – Unnamed Function #2

This answers the Problem of the Week from May 8, 2012. The identity of this well-known computer science function is the binary search. The following is the same code from before with the variables more properly named: To tell you the truth, after using the real names in the function Read more…

By Chris West, ago
Blog

POW – Unnamed Function #2

This Problem of the Week involves determining the identity of a well-known computer science function and renaming the variables so that the definition makes more sense.  The following is the function definition (obfuscated by me): What I can tell you is that this function takes in a sorted array (in ascending order) as the Read more…

By Chris West, ago