Sum an Array of Numbers with JavaScript

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

Shilling for Putin

The Insider (‘fully committed to investigative journalism and to debunking fake news’) has created a new interactive map which exposes the ‘fake experts’ around the world that are spreading pro-Kremlin fake narratives and Russian propaganda. The Insider claims that what “unites the individuals featured on this map is their attempt to portray Putin’s policies positively while disseminating Maps Mania… more →
Posted in: Interactive Maps

How to Detect Failed Requests via Web Extensions

One of the best things that ever happened to t he user experience of the web has been web extensions. Browsers are powerful but extensions bring a new level of functionality. Whether it’s crypto wallets, media players, or other popular plugins, web extensions have become essential to every day tasks. Working on MetaMask, I am thrust into a world of making everything Ethereum-centric work. One of those functionalities is ensuring that .eth domains resolve to ENS when input to the address bar. Requests to https://vitalik.ethnaturally fail, since .eth isn’t a natively supported top level domain, so we need to intercept this errant request. // Add an onErrorOccurred event via the... more →
Posted in: JavaScript

Guess the (Marvel) Decade

Many years ago, I first wrote up my experience working with the Marvel API. I find myself returning to it again and again, and this weekend I built a fun little game I think you may enjoy. It’s called "Guess the Decade". Marvel’s art style has changed drastically over its long history. Back in 2018, I shared a demo that demonstrates just how much variety you can get just by looking at covers. So for example, Spider-Man in 1962: Versus 1988: And then 2018: Given that there’s such a variety of styles, I thought it would be fun to build a demo. If you want, you can just right to the game, but here’s how I built it. The Backend # For the backend, I built a serverless... more →
Posted in: JavaScript

More Medieval Murder Maps!

On Saturday 2 Feb 1297 three Oxford University students decided to celebrate the festival of the purification of the Blessed Virgin Mary by going on a frenzied rampage. On the evening of the festival John de Skurf and his two friends Michael and Madoc ran through the streets of Oxford with swords, bows, and arrows “attacking all passers-by”. One John Metescharp was shot with an arrow by Maps Mania… more →
Posted in: Interactive Maps

Welcome to the New LimeWire: AI Media Generation (Sponsored)

LimeWire was a staple of my youth. LimeWire was software that allowed users to share any type of file during the revolutionary days of file sharing. Fast forward to today and LimeWire is back, again as revolutionary software, but this time in the field of AI content publishing. From creating images to music and video, and then monetizing that media, LimeWire continues to be a hub of creativity! Quick Hits LimeWire has re-launched as an AI-focused content publishing & community platform LimeWire AI Studio is now live for AI Image Generation! Generative AI music & video coming soon! Automatically mint AI-generated content as NFTs on the Polygon and Algorand blockchains LimeWire has an... more →
Posted in: JavaScript

Restricting the Right to Protest

The right to protest is being restricted in countries around the world. Amnesty International’s new interactive map, called Protect the Protest, highlights the growing numbers of human rights violations which are being committed by countries around the world aimed at removing the rights of citizens to legally protest. The Protect the Protest map sheds light on the types of repression that are Maps Mania… more →
Posted in: Interactive Maps

Testing Out the Alpine.js Intersect Plugin

A few weeks ago, I finally got around to looking at the official plugins Alpine.js supports and built a little demo that integrated the Intl spec with the Mask plugin. (You can read the post here: Integrating Intl with Alpine.js Mask). Today I thought I’d take a look at another plugin, Intersect. What Is It? # The Intersect plugin is a wrapper for the Intersection Observer API. This is a pretty cool web platform API that lets you monitor when DOM elements come into the visible part of a web browser. I first dug into this a few months ago in an article I wrote for Cloudinary, "Automatically Loading High-Quality Images with Cloudinary and IntersectionObserver". In that article,... more →
Posted in: JavaScript
1 34 35 36 37 38 190