## JavaScript Snippet – suffixFileSize()

If you would like to convert the amount of bytes (or bits) into the corresponding measure when the size is a kilobyte or bigger (or a kilobit or bigger) you can use the following JavaScript function: Here are some examples of using it: If you would like to know how Read more…

## JavaScript Snippet – isPowerOf(x, base)

After reading this reddit entry I decided to write up a little snippet with documentation: Feel free to use it whenever and wherever. Happy coding! ðŸ˜Ž

## 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…

## 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…

## Symbolic Mind Meld

Your computer may be able to read your mind if you are good at simple math. Try it out below or go here.

## JavaScript Snippet – Using Degrees with Cosine, Sine & Tangent

Now Available in YourJS Yesterday I was working with Math.cos, Math.sin and Math.tan and was thinking it would be nice to have the equivalent functions which accept the values in degrees instead of radians. For that reason I wrote the following definitions for Math.cosd, Math.sind and Math.tand: After executing the Read more…

## 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…

## 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…

## 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…

## JavaScript – Fraction Part of a Number

One thing that is common knowledge about JavaScript and other languages is that floating point numbers are not always stored the way you think. Also doing math with these numbers is even more iffy. One thing I recently wanted to do was effectively the opposite of parseInt(). In other words, Read more…