Nikhilesh Aleti has Published 93 Articles

Reorder an array in JavaScript

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 22-Sep-2022 12:04:11

8K+ Views

The given task is to reorder an array in JavaScript. We can reorder the elements in the array by using the following methods. One of the ways to achieve the above task is b using sort() method. The sort() is an in-built method in JavaScript, which sorts the alphabetic elements. ... Read More

Generating random hex color in JavaScript

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 22-Sep-2022 12:00:55

2K+ Views

The Hex (Hexadecimal) code is a six-digit code and a three-byte hexadecimal number that is used to represent the colors. These three bytes represent RGB which means the amount of red, green, and blue in a particular shade of a color. Each byte will represent a number in the range ... Read More

Return an array of all the indices of minimum elements in the array in JavaScript

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 22-Sep-2022 11:59:23

685 Views

An Array in JavaScript is a single variable where it can store different elements. These elements are stored at contiguous memory locations. Array elements can be accessed with the help of index numbers. The index numbers will start from 0. Syntax Below is the basic declaration of the array in ... Read More

How to remove the 0th indexed element in an array and return the rest of the elements in JavaScript?

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 19-Sep-2022 09:03:41

594 Views

Array is a structure, which can hold values elements and they can be accessed by referencing to them with the help of index numbers. Const colors = [“Green”, “Maroon”, “Blue”]; Reference index of array In JavaScript arrays are referred with reference indexes. These indexes are zero-indexed. The very first ... Read More

Is 'floating-point arithmetic' 100% accurate in JavaScript?

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 19-Sep-2022 08:53:21

406 Views

Floating point A number which is either positive or negative whole number with having a decimal point to it is called floating point. Let’s consider these numbers, 1.52, 0.14 and also -98.345 are considered as floating point numbers. Whereas 77, 56, 90 and 0 are not considered as floating point ... Read More

How to convert a string to a floating point number in JavaScript?

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 19-Sep-2022 08:46:33

862 Views

In this article, we are going to discuss how to convert a string to a floating-point number in JavaScript. We can convert a string to a floating point in three ways − Using the parseFloat() method. Using the parseInt() method. Using type conversion. Using the parseFloat() method The ... Read More

How to find the common elements between two or more arrays in JavaScript?

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 19-Sep-2022 08:13:58

9K+ Views

Arrays is typeof operator in JavaScript. Arrays can access its elements with the help of index numbers which starts with 0. Let array = [“India”, “Australia”, “USA”]; There are enough number of ways to get the common elements from the arrays. Now, In this below scenario we use for ... Read More

How to check whether provided elements in an array have passed a specified condition or not in JavaScript?

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 19-Sep-2022 08:00:52

108 Views

In this article, we are going to discuss whether provided elements in an array have passed a specified condition or not in JavaScript. Here, we can use the _.filter() method, every() method, some() method, filter() method, and for loop. They return true if every element in an array has met ... Read More

How to select a radio button by default in JavaScript?

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 19-Sep-2022 07:57:16

12K+ Views

Radio button A radio button is used to select one among many options. This is one of the element in HTML. This radio button is a radio group to show a set of multiple choices, and in that only one can be selected. This way far similar to checkboxes, in ... Read More

How to add an event handler to the specified element in JavaScript?

Nikhilesh Aleti

Nikhilesh Aleti

Updated on 19-Sep-2022 07:26:19

279 Views

Events in HTML are “things” that take place using HTML elements. JavaScript can “respond” to these events when used in HTML pages. Events are produced as a result of user interaction with the elements of the user interface. The actions that trigger an event include, for instance, pressing a button, ... Read More

Advertisements