How to use Reduce in JavaScript

reduce is an array method that helps you convert an array into a single value. It looks like this:

const callback = (accumulator, currentValue, index) => {
// return something here
const result = array.reduce(callback, initialValue)
  • initialValue is the value you want to start with.
  • accumulator is the value returned from the previous iteration. It will be initialValue for the first iteration.
  • currentValue is array item in the current iteration.

Let’s go through some examples.

Choosing between Netlify, Vercel and Digital Ocean

A while back, I jumped onto the hype train and tried to host Learn JavaScript’s marketing page on Netlify — I wanted to join the cool kids. After getting charged for it, I switched to Vercel and I got charged for it (again). I finally went back to good old Digital Ocean.

In this article I want to detail the differences between hosting on Netlify, Vercel, and Digital Ocean, along with what I experienced in the process.

How to write super simple and useful regular expressions for the real world

Regular expressions are HARD! They look so complicated, they’re turn me off completely most of the time. Sometimes I wished I was smarter so I can use them more effectively.

While working on Learn JavaScript, I noticed that using regular expressions effectively doesn’t mean you need to write complicated regex. You can write super simple regex that solves a ton of problems.

I’m going to show you a real example.

Year End Review — 2020

Hello! I want to begin the year with a year-end review again. I like doing these because it gives me a solid sense of where I am today versus where I was last year.

Giving away 10 copies of Learn JavaScript

I want to start 2021 on a good note by giving away 10 copies of my JavaScript course, Learn JavaScript. This course will help you become great at JavaScript within a short span of time. The usual price for this course is $495, so I’m gonna give away $4950 worth of value.

Rik Schennink is also joining me and giving away 5 lifetime Hobby license for his amazing Image Editor plugin, Doka. Each hobby plan is priced at $149, each year, so Rik is giving away a ton too!

Case Conversion in JavaScript

I got fed-up searching Google for case conversion utilities. The useful ones I found (Voca and change-case) both require an environment that allows me to use npm.

But I was using Vanilla JavaScript. I did not want to include any toolchains in this project, and I’m reluctant to send an asynchronous request to download a module just for case-conversion.

So I decided to write a set of conversion utilities myself.

It’s simpler than I thought.

Why we should use Ergonomic keyboards

Normal keyboards create tension in the wrists, which eventually lead to backaches. In this article, I explain how that connection happens and why we should use ergonomic keyboards.

What’s the difference between an Interface and an API?

I used to think JavaScript doesn’t have Interfaces because it doesn’t have the Interface keyword, unlike Java.

Interface keyword in Java

But JavaScript DOES have interfaces. I found out about this when I tried Googling for the location API, which turned out to the location Interface 🤦‍♂️.

Location interface.

I was confused. What the hell is the difference between an interface and an API? I sat down and figured it out (as usual). I want to share my newfound understanding with you in this article.

Let’s begin with interfaces.

Understanding JavaScript Prototype

JavaScript is said to be a Prototype-based language, so “prototypes” must be an important concept. Right?

Today I’m going to explain what Prototypes are, what you need to know, and how to use Prototypes effectively.

Hold on while i sign you up…

Woohoo! You’re in!
Now, hold on while I redirect you.