Match Specific Word in Regex in JavaScript

Nikhilesh Aleti
Updated on 22-Sep-2022 12:05:51

11K+ Views

The task is to match a specific word or character which is in regex with a string. The regex (regular expressions) is a pattern that is used to match character combinations in strings. Here we include the test(), match(), and matchAll() methods to match the following word in regex. We have some boundary-type assertions, in which we have used \b. Consider a sentence – “mickey is holding mic.” Using regex - \bmic\b will match the word mic but not the word mic in mickey. It is a word boundary. Another assertion is (g), It is a global search flag. Consider ... Read More

Reorder an Array in JavaScript

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

9K+ 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. By default, it sorts in ascending order. Example Following is the example where the array got reordered in ascending order − const States = ["Telangana", "Uttar Pradesh", "Karnataka", "Kerala", ... Read More

Generate Random Hex Color in JavaScript

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 00 to FF (Hexadecimal notation) or 0 to 255 in decimal notation. This indicates the intensity of each of the color components from 0 to 255. The following are the functions to be used for generating random hex codes − Math.random() is used to get the number randomly in the ... Read More

Return Indices of Minimum Elements in Array in JavaScript

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

962 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 JavaScript − Cosnt cars = [Maruti, Hyundai, Honda]; We need to return an array of all the indices of minimum elements in a JavaScript array Let’s look into the input-output scenario Assume there is an integer array where the minimum element is repeated more than once. We need to ... Read More

Find Index of Object in List in Python

Vikram Chiluka
Updated on 22-Sep-2022 08:56:48

6K+ Views

In this article, we will show you how to find the index of an object in a given input list using python. Below are the 3 different methods to accomplish this task − Using index() method Using For Loop Using List comprehension and enumerate() Function Assume we have taken a list containing some elements. We will return the index of a specified object in a given input list. Method 1: Using index() method The index() function in Python allows you to find the index position of an element or item within a string of characters or a list ... Read More

Declare an Attribute in Python Without a Value

Vikram Chiluka
Updated on 22-Sep-2022 08:53:00

5K+ Views

In this article, we will show you how to declare an attribute in python without a value. In Python, as well as in several other languages, there is a value that means "no value". In Python, that value with no value is None, let us see how it is used. You simply cannot. Variables are just names in Python. A name always refers to an object ("is bound"). It is conventional to set names that do not yet have a meaningful value but should be present to None. Method 1: By Initializing them with None Directly We can directly assign ... Read More

Difference Between Windmill and Wind Turbine

Manish Kumar Saini
Updated on 22-Sep-2022 08:43:06

5K+ Views

The energy of flowing wind is a versatile source of renewable and sustainable energy. In practice, people use the terms Windmill and Wind Turbine interchangeably, but these two terms are different from each other. Windmill and wind turbines are different from each other in structure and application. Windmill is a technology in which energy of wind is used to mill grains, moving water, driving machines, etc. On the other hand, a wind turbine converts the wind energy into electrical energy by driving a generator connected to it. In this article, we will discuss all the noticeable differences ... Read More

Concatenation Operator on Lists in Python

Vikram Chiluka
Updated on 22-Sep-2022 08:39:58

806 Views

In Python, a list is an ordered sequence that can hold several object types such as integer, character, or float. In other programming languages, a list is equivalent to an array. Concatenation of lists is an operation that adds the elements of one list to the end of another. We're discussing list data structures here, therefore we'll join the elements of one list to the end of another. In this article, we will show you how to concatenate lists in python. The following are the different methods to accomplish this task − Using Concatenation(+) Operator Using For Loop(Naive Method) ... Read More

Difference Between Valence Band and Conduction Band

Manish Kumar Saini
Updated on 22-Sep-2022 08:36:20

10K+ Views

In atomic structure, valance band and conduction band are the terms used to represent the energy levels of the subatomic particles, usually electrons. While analyzing the atomic structures, we found that the valance band and conduction band are separated by a certain amount of energy depending on the type of material. For example, in metals, these are touching each other; in semi-conductors, these are separated by a moderate amount of energy; and in case of insulators, this separation is very large. The energy gap between the valance band and the conduction band is known as forbidden energy gap. The diagram ... Read More

Difference Between Transformer and Amplifier

Manish Kumar Saini
Updated on 22-Sep-2022 08:35:08

3K+ Views

In electrical and electronics engineering, transformers and amplifiers play a crucial role in several circuits. At first sight, the function of a transformer and an amplifier may seem similar, that is, increasing the level of voltage. But, a transformer can reduce the level of voltage as well, whereas an amplifier cannot. In this article, we will discuss all the key differences between a transformer and an amplifier by considering different parameters such as basic definition, circuit components, primary function, applications, etc. But before that, let's check some of the basics of transformers and amplifiers so that it becomes easier ... Read More

Advertisements