Recognizing Abundant, Deficient, and Perfect Numbers / / No Comments Ok, this post falls into the "I’ll never actually use this again" category, which frankly, my normal readers know happens all the time, but it was a fun little diversion and a reminder of why I used to love math so much. Yesterday I found out that one of my kids’ homework was to look at a set of numbers and determine if they were abundant, deficient, or perfect. Right now you are probably (at least I know I was) asking, "what in the actual heck is that???" A quick bit of Googling turned up this explainer that basically boils it down to a simple principal. Given a number, find all the divisors of that number, excluding the number itself, and add them up. If the... more → Posted in: JavaScript Tagged with: Abundant, Deficient, numbers, Perfect, Recognizing
Adventures in Vibe Coding – Really, Really Big Numbers / / No Comments I continue to be really against the term ‘vibe coding’, but also continue to be fascinated by the idea of working with GenAI to help craft/enhance applications in an iterative, conversation-based manner. Ashley Willis recently released an incredibly well done post on the topic, "What Even Is Vibe Coding?", where she goes into detail on her take on the term and what it means for the industry. I think it is an excellent post and I want to highlight one part that really resonated with me: It scaffolds layouts, creates routes, fills in placeholder content, basically roughs out the shape of the thing I described. I still review it, refactor it, test it, and shape it into something... more → Posted in: JavaScript Tagged with: Adventures, coding, numbers, really, Vibe
Sum an Array of Numbers with JavaScript / / No Comments It’s rare that I’m disappointed by the JavaScript language not having a function that I need. One such case was summing an array of numbers — I was expecting Math.sum or a likewise, baked in API. Fear not — summing an array of numbers is easy using Array.prototype.reduce! const numbers = [1, 2, 3, 4]; const sum = numbers.reduce((a, b) =a + b, 0); The 0 represents the starting value while with a and b, one represents the running total with the other representing the value to be added. You’ll also note that using reduce prevents side effects! I’d still prefer something like Math.sum(...numbers) but a simple reduce will do! The post Sum an Array of Numbers... more → Posted in: JavaScript Tagged with: Array, JavaScript, numbers
How to Internationalize Numbers with JavaScript / / No Comments Presenting numbers in a readable format takes many forms, from visual charts to simply adding punctuation. Those punctuation, however, are different based on internationalization. Some countries use , for decimal, while others use .. Worried about having to code for all this madness? Don’t — JavaScript provides a method do the hard work for you! The Number primitive has a toLocaleString method to do the basic formatting for you: const price = 16601.91; // Basic decimal format, no providing locale // Uses locale provided by browser since none defined price.toLocaleString(); // "16,601.91" // Provide a specific locale price.toLocaleString('de-DE'); // "16.601,91" // Formatting... more → Posted in: JavaScript Tagged with: Internationalize, JavaScript, numbers
RSPB calls for public to help map swift nests using new app as numbers have more than halved – Telegraph.co.uk / / No Comments RSPB calls for public to help map swift nests using new app as numbers have more than halved Telegraph.co.uk “map app” – Google News… more → Posted in: Interactive Maps Tagged with: Calls, halved, help, More, nests, numbers, public, RSPB, Swift, Telegraph.co.uk, than, using