Found 10483 Articles for Web Development

JavaScript Program to Count Rotations Divisible by 4

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

213 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

190 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 03-Dec-2024 14:37:26

3K+ Views

To check whether a given number is power of 2 in JavaScript, we can check if the number is generated using multiplying 2's only. We will be discussing 5 different approaches to check whether a given number is a power of 2. In this article we are having two numbers, our task is to check whether a given number is power of 2 in JavaScript. Users must be familiar with JavaScript Math functions, loops, binary representation and bitwise operators. Approaches to Check if a Number is Power of 2 Here is a list of approaches to check whether ... 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 22-Nov-2024 11:06:00

9K+ Views

To get value of selected radio button using JavaScript is useful to a user in various ways such as collecting surveys data, in quiz or dynamic UI updates like changing to dark or light theme. We will be discussing two approaches to get the selected radio button value. In this article, we are having three radio buttons with their labels and our task is to get value of selected radio button using JavaScript. Approaches to Get Value of Selected Radio Button Here is a list of approaches to get value of selected radio button using JavaScript which we will be ... Read More

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

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

25K+ 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

278 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

2K+ 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

How to Display the Chemistry Formula in the HTML Input?

Yaswanth Varma
Updated on 20-Apr-2023 17:00:54

2K+ Views

In HTML, for displaying the chemistry formula in the HTML input, we are going to use the subscript and superscript tags. Let’s consider a simple example. Chemical formula of water is H2O For the above, we are going to apply the HTML superscript and subscript tags to get the output of the chemical formula as mentioned above. Chemical formula of water is H2O Let’s dive into the following article for getting the better understanding on displaying the chemistry formula in the HTML input. HTML Subscript Inline text that should be displayed as subscript purely for typographical reasons is specified ... Read More

How To Password Protect A Page Using Only HTML, CSS And JavaScript?

Yaswanth Varma
Updated on 24-Oct-2024 17:29:01

25K+ Views

To password protect a page using only HTML, CSS and JavaScript, is an important security measure for webpages that contain sensitive information or require authentication for access. In this article, we will understand how to create a simple form that requires users to enter a password before they can view the content of your protected page. In this article, we are having some textual information, our task is to password protect page using only HTML, CSS and JavaScript. Approaches to Password Protect a Page Here is a list of approaches to password protect a page using only HTML, CSS and ... Read More

Advertisements