Photo by Markus Winkler on Unsplash

React is an easy to use JavaScript framework that lets us create front end apps.

In this article, we’ll look at how to create a percentage calculator with React and JavaScript.

Create the Project

We can create the React project with Create React App.

To install it, we run:

with NPM to create our React project.

Create the Percentage Calculator

To create the percentage calculator, we write:


Photo by Ryan Kwok on Unsplash

React is an easy to use JavaScript framework that lets us create front end apps.

In this article, we’ll look at how to create a recipe app with React and JavaScript.

Create the Project

We can create the React project with Create React App.

To install it, we run:

with NPM to create our React project.

We also need the uuid package to let us generate unique IDs for our recipe items.

To do this, we run:

Create the Recipe App

To create the recipe app, we write:


Photo by Coffee Geek on Unsplash

Comparing object properties and values is something that we need to do sometimes in our JavaScript code.

In this article, we’ll look at how to compare objects in JavaScript.

JSON.stringify

The JSON.stringify method lets us convert a JavaScript object into a JSON string.

Once we converted our object into a string, we can compare the stringified value against another object that’s stringified.

For instance, we can write:

We have 2 objects, obj1 and obj2 .

Then we call JSON.stringify on both objects and check…


Photo by Macau Photo Agency on Unsplash

Formatting numbers as currency stings is something that we have to do sometimes in our JavaScript apps.

In this article, we’ll look at how to format numbers as currency strings with JavaScript.

The Intl.NumberFormat Constructor

We can use the Intl.NumberFormat constructor that comes with most browsers to format a number into a currency string.

For instance, we can write:

We pass in the locale and an object with formatting options arguments of the constructor.

style is set to 'currency' to format a number into a currency string.


Photo by Bruna Araujo on Unsplash

Getting the screen size is important if we want to create responsive web apps.

Therefore, this is an operation that’s frequently done within JavaScript web apps.

In this article, we’ll look at how to get the size of the screen, web page, or browser window with JavaScript.

Use the window.screen Object to Get a Screen’s Dimensions

The window.screen object lets us get the height and width of the browser’s screen with the height and width properties respectively.

For instance, we can write:

to get the height and width of the screen that the app is currently on.

Window innerWidth and innerHeight Properties

The window.innerWidth and window.innerHeight properties let us get the current…


Photo by Christina Rumpf on Unsplash

Removing an item from a JavaScript array is something that we have to do often.

In this article, we’ll look at how to remove a specific item from a JavaScript array.

The indexOf and splice Methods

One way to remove an item from an array is to use the indexOf method to get the index of the item we want to remove.

Then we can use the splice method to remove an item with the given index.

For instance, we can write:

We have the array


Photo by CHUTTERSNAP on Unsplash

React is an easy to use JavaScript framework that lets us create front end apps.

In this article, we’ll look at how to create a PIN pad with React and JavaScript.

Create the Project

We can create the React project with Create React App.

To install it, we run:

with NPM to create our React project.

Create the PIN Pad

To create the PIN pad, we write:


Photo by Sam Moqadam on Unsplash

React is an easy to use JavaScript framework that lets us create front end apps.

In this article, we’ll look at how to create a grade calculator with React and JavaScript.

Create the Project

We can create the React project with Create React App.

To install it, we run:

with NPM to create our React project.

Also, we’ve to install the uuid package to let us assign unique IDs for each grade entry.

To do this, we run:

Create the Grade Calculator

To create the grade calculator, we write:


Photo by Anne Nygård on Unsplash

If we’re working with web front end apps, then changing an element’s class is something that we’ve to do often.

In this article, we’ll take a look at how to change an element’s class with JavaScript.

The classList Property

An element has the classList property to let us manipulate the classes that are applied to the element.

For instance, if we have a div:

Then to add a class to the div, we can write:

We call add to add the 'hello' class to the div.

If the hello class is already added, then nothing will be done.


Photo by Devon Janse van Rensburg on Unsplash

Trimming off the last character in a JavaScript string is something that we’ve to do often.

In this article, we’ll look at how to trim off the last character in a JavaScript string.

String.prototype.substring

We can use the substring method available in a string instance to return a substring of the string it’s called on.

For instance, we can use it by writing:

We have the str string which we want to remove the last character from.

Then we call substring with the start and end indexes which we want…

John Au-Yeung

Web developer. Subscribe to my email list now at https://thewebdev.info/subscribe/. Email me at hohanga@gmail.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store