Found 8895 Articles for Front End Technology

JavaScript Program to check idempotent matrix

Prabhdeep Singh
Updated on 20-Apr-2023 17:16:20

95 Views

An idempotent matrix is a square matrix that has the same number of rows and columns and when we multiply the matrix by itself the result will be equal to the same matrix. We will be given a matrix and we have to find that whether it is an idempotent matrix or not. Mathematically − If the given matrix ix M, then of M to be an idempotent matrix is should follow the property − M*M = M Multiplication of Matrix Multiplication of a matrix with another matrix produces another matrix and if the given matrix is the square ... Read More

JavaScript Program to Count Rotations Divisible by 8

Shubham Vora
Updated on 20-Apr-2023 17:02:54

91 Views

Problem Statement − We have given a number. We need to rotate the number and need to find the total number of rotations divisible by 8. Here, we will learn two different approaches to counting rotations divisible by 8. Rotate the Number and Check if Rotation is Divisible by 8 The first approach is to rotate numbers and get every possible rotation one by one. Also, check if rotation is divisible by 8. If yes, add 1 to the count. Syntax Users can follow the syntax below to count rotations divisible by 8 by rotating the numbers. for ( ) ... Read More

JavaScript Program to Count Rotations Divisible by 4

Shubham Vora
Updated on 20-Apr-2023 17:02:19

98 Views

In this tutorial, we will learn to count the total number of rotations divisible by 4 for the given number. Problem statement − We have given a number value. We need to rotate numbers in clockwise or anti-clockwise directions and count the total number of rotations divisible by 4. Here, we will learn two different approaches to counting rotations divisible by 4. Rotate the Number and Check if it is Divisible by 4 In this approach, we will convert the number to a string first. We can make n rotations for the string of length n. We will remove the ... Read More

JavaScript Program to Count Inversions of size three in a given array

Shubham Vora
Updated on 20-Apr-2023 17:00:45

105 Views

In this tutorial, we will learn to count inversions of size three in a given array. Problem statement − We have given an array of length n containing the different numeric entries. We need to find the total number of pairs of numbers of size 3 such that arr[i] > arr[j] > arr[k], where I < j < k. Here, we will learn the brute force approach first and after that, we will optimize its time and space complexity. Using the Brute Force Approach In the brute force approach, we will use three nested for loops to find a count ... Read More

JavaScript program to check whether a given number is power of 2

Shubham Vora
Updated on 20-Apr-2023 16:53:35

2K+ Views

The given number is a power of 2 if the number is generated using multiplying 2’s only. In this tutorial, we will learn to check whether a given number is a power of 2. Here, we will look at 5 different approaches to check whether a given number is a power of 2. Using the Math.pow() Method In JavaScript, the number can contain 64 bits most. So, we can use the for loop and Math.pow() method to find the 1 to 64 power of the 2. For loop, we can compare the ith power of 2 with the number. If ... Read More

How to conditionally add a member to an object using JavaScript?

Shubham Vora
Updated on 20-Apr-2023 16:32:29

3K+ Views

The object is the most important data type of JavaScript. Even everything is an object in JavaScript. For example, Array is an object, and Number, String, and Boolean can also be an object. Sometimes, developers require to insert properties into the object based on some condition. For example, we have an object of the person, and we only require adding the driving licence property if a person is 18 years old. Here, we will learn different approaches to adding a member to an object using JavaScript conditionally. Using the Spread Operator to add a Member to an Object Conditionally The ... Read More

How to Get Value of Selected Radio Button Using JavaScript?

Yaswanth Varma
Updated on 20-Apr-2023 17:10:57

5K+ Views

One of the most important HTML components when attempting to design a form is the radio button. The user can only select one choice from the alternatives shown to him by the radio buttons. Typically, we just utilize the element's value attribute in JavaScript to retrieve an element's value from an HTML webpage. But with radio buttons, we can't do that. The reason is that getting the values of individual radio buttons is a bad idea. Let's get started with the article to learn how to get the value of a selected radio button. For this, we are going to ... Read More

How To Create A Text Inside A Box Using HTML And CSS

Yaswanth Varma
Updated on 02-Jul-2024 16:47:09

16K+ Views

To create a text inside a box using HTML and CSS, we will be understanding most commonly used approaches in this article. We are having a element, inside that element we will have element. We need to to place some charecter of the p element inside a box, or create a border surrounded those charecters. Approaches to Create a Text Inside a Box Using span element with CSS Using CSS flexbox Creating a Text inside a Box Using span Element To create a text inside a box using ... Read More

How to Match Width of Text to Width of Dynamically Sized Image/Title?

Yaswanth Varma
Updated on 20-Apr-2023 17:06:12

134 Views

In this article, we are going to learn how to match the width of text to the width of a dynamically sized image or title. Let's get into the article to learn more about matching the width of text to the width of an image. Matching width of text to width of image To insert an image inside a webpage or website, use the HTML tag. In modern websites, images are linked to web pages using the element, which contains space for the image. This prevents websites from directly adding images to web pages. Syntax Following is the ... Read More

How To Extract Text From A HTML Tag In Text Format?

Yaswanth Varma
Updated on 23-Nov-2023 12:36:42

1K+ Views

The act of extracting text from an HTML file is essentially equivalent to copying and pasting website content onto a notepad. It might sound easy, but it wouldn't be as enjoyable if you had to extract text from millions of HTML files (webpages). Let's dive into the article for getting better understanding on extracting text from a HTML tag in text format. Extracting text from HTML tag Numerous elements in HTML can be used to give text a specific meaning. For getting more idea on extracting text from a HTML tag in text format, let's look into the following examples. ... Read More

Advertisements