## How to call a JavaScript function from HTML

In this tutorial, let’s look at the different ways of calling a JavaScript function from HTML. 1. We’re going to start off by creating an inline script tag right within our HTML page. This tag will host our function, and we’re going to call it by using the onClick method. 2. Then, let’s look at … Read more

## How to find the factorial of a number in JavaScript

In this tutorial, let’s look at the different ways of finding the factorial of a number in JavaScript. To start with, we’re going to look at the iterative approach, where we’ll be looking at using both the while and for loops. In the next section, let’s look at using recursive functions to achieve our purpose. … Read more

## Get last element of array JavaScript

In this tutorial, let’s look at how to get the last element of an array in JavaScript. We’re going to start with the simplest method of extracting the last element by just accessing it using its index. Then, we’re going to move on to pre-defined methods like slice, splice, at and so on. Finally, let’s … Read more

## How to disable a button in JavaScript?

In this tutorial, we’ll look at how to disable a button in JavaScript. We’ll be looking at 1. How to retrieve the button element in JavaScript, 2. Then 2 different ways to disable it from within your script file, 3. How to conditionally disable a button and finally, 4. How to toggle between enabled and … Read more

## JavaScript repeat string

In this tutorial, we’re going to figure out ways to repeat the same string ‘n’ number of times, where n is a positive whole number. ES6 repeat() method The easiest way of doing this is by using the repeat() method, which is a pre-defined method in JavaScript. Introduction In the example below, I’ve created a … Read more

## How to check if a string is a number in JavaScript?

In this tutorial, we’re going to look at the different ways to check if a string is a number in JavaScript. Let’s first look at the main way of checking if a string is a number first, and then also look at ways of converting a string to a number, and then checking if the … Read more

## How to remove the first character from string in JavaScript

In this tutorial, let’s look at how to remove the first character from string in JavaScript. We’re going to look at 1. The slice method, 2. Then, the substring method, which is quite like slice, 3. The replace method, and using regular expressions with it 4. Array methods like fill, shift and join that can … Read more

## How to remove last character from string JavaScript

In this tutorial, we’ll be looking at the different ways to remove the last character of a string in JavaScript, starting from using negative indexing in the slice() method to using regular expressions in the replace() method. We’ll also be looking at ways to remove more than one character from the end of the string. … Read more

## JavaScript String slice – a detailed look

In this tutorial, we’re going to get a detailed look into the JavaScript string slice method. We’re going to look at the basics of it, then how to use the various arguments at our disposal, how to send negative values as arguments, how the negative values change the output, and a lot more. So, let’s … Read more

## JavaScript string endsWith

In this tutorial, let’s look at how to use the String endsWith method in JavaScript. This method can be used to check whether the string ends with a given substring/string/character, and based on the result, you can assign if else or switch case statements that manipulate the program/data as you see fit. Introduction to the … Read more