Blog

ES6 – Convert To Integer

There are various ways to convert a string or a floating point number to an integer in JavaScript, but not all of them may suit your needs. In this post we will examine four different ways and then we will see which is the best in all cases. Solution #1: Read more…

By Chris West, ago
Blog

365.2425 Days in a Year?

I was looking through some of the posts on Google+ and noticed that one of Douglas Crockford’s posts alluded to the fact that there are 365.2425 days on average in a year. At first I thought that the number should’ve actually been 365.25 due to us seeing a leap year Read more…

By Chris West, ago
Blog

POW Answer – Circle, Square, Circle

Last week’s problem involved using your geometry/trigonometry skills to find areas of shapes. We start off with a large (black) circle which has a (black) square inscribed in it which in turn has a (red) circle inscribed in it: Let’s start off with the equation for the area of a Read more…

By Chris West, ago
Blog

POW – Circle, Square, Circle

Recently a friend asked why I haven’t put up any new POWs (Problems of the Week). Part of the reason is because I got lazy but the other part is because the show Numb3rs is what inspired me before and I haven’t been watching any reruns lately 😛. Yesterday I Read more…

By Chris West, ago
Blog

JavaScript – Parsing A Number

If you should ever need to parse a number into an array of bits or a different base you can use the following function: var splitNumber = (function(MAX) {   for (; MAX + 1 – MAX == 1; MAX *= 2){}   return function (num, radix) {     // Validate num     num Read more…

By Chris West, ago