Web Development Articles

Page 427 of 801

How to get the maximum count of repeated letters in a string? JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

We have a string that contains some repeated letters like this: const a = "fdsfjngjkdsfhhhhhhhhhhhfsdfsd"; Our job is to write a function that returns the count of maximum consecutive same letters in a streak. Like in the above string the letter 'h' appears for 11 times in a row consecutively, so our function should return 11 for this string. This problem is a good candidate for the sliding window algorithm, where a stable window contains consecutive identical letters and one that contains different elements is unstable. The window adjusts by moving the start pointer when different characters ...

Read More

Fetch Second minimum element from an array without sorting JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 547 Views

We have an array of Numbers, and we are required to write a function that returns the second smallest value from the array. For example − if the array is − const arr = [67, 87, 56, 8, 56, 78, 54, 67, 98, 56, 54]; Then the output should be the following − 54 because 54 is the smallest value after 8 Method 1: Using indexOf and splice This approach finds the minimum element, removes it from a copy of the array, then finds the minimum of the remaining ...

Read More

How to create a weight converter with HTML and JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 466 Views

Creating a weight converter with HTML and JavaScript involves building a simple form that takes weight input in one unit and converts it to another unit in real-time. This tutorial demonstrates how to create a kilogram to gram converter. HTML Structure The HTML provides the basic structure with an input field for kilograms and a display area for the converted grams: body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } input, span{ ...

Read More

How to create a temperature converter with HTML and JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 842 Views

To create a temperature converter with HTML and JavaScript, you need to combine form elements with JavaScript functions to perform real-time temperature conversions. Complete Temperature Converter Example body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 600px; margin: 50px auto; padding: 20px; } .converter-container { background: #f8f9fa; border-radius: ...

Read More

Get n numbers from array starting from given point JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 325 Views

We need to create a custom Array method that extracts n elements from an array starting at a given index, moving in a specified direction (left or right). When we reach array boundaries, the function wraps around to continue from the other end. Problem Requirements The function should take three parameters: n - number of elements to extract m - starting index (must be ≤ array.length - 1) direction - either 'left' or 'right' For example, if we have [0, 1, 2, 3, 4, 5, 6, 7] and call get(4, 6, 'right'), it should return ...

Read More

How to create a length converter with HTML and JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

To create a length converter with HTML and JavaScript, you'll need to combine HTML form elements with JavaScript functions to handle the conversion logic. This tutorial demonstrates building a simple kilometer-to-meter converter. HTML Structure The converter uses an input field for kilometers and displays the converted meters value. The oninput and onchange events trigger the conversion function automatically as you type. Complete Example body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; padding: 20px; ...

Read More

How to create a speed converter with HTML and JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 384 Views

To create a speed converter with HTML and JavaScript, we'll build a simple web application that converts kilometers per hour to meters per second. This involves HTML for the interface and JavaScript for the conversion logic. HTML Structure The HTML creates the user interface with an input field for entering speed values and a display area for the converted result: body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; padding: 20px; ...

Read More

Among id, name, xpath and css, which locator should be used?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 455 Views

When selecting locators for web automation, the choice depends on element uniqueness, performance requirements, and traversal needs. Here's a comprehensive guide to choosing the right locator strategy. Locator Priority Order The recommended priority order for locator selection: Priority Locator Reason 1 id Fastest, most reliable if unique 2 name Fast, good for form elements 3 CSS Selector Fast, flexible, good performance 4 XPath Most flexible but slower When to Use Each Locator ID Locator Use when elements have unique IDs. This is the ...

Read More

How to identify the nth sub element using xpath?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 7K+ Views

We can identify the nth sub element using xpath in the following ways: By adding square brackets with index. By using position() method in xpath. Method 1: Using Square Brackets with Index The most common approach is to add square brackets with the desired index number after the element selector: // Select the 2nd div element //div[2] // Select the 3rd li element inside ul //ul/li[3] // Select the first input with type='text' //input[@type='text'][1] Method 2: Using position() Function The position() function provides another way to target elements ...

Read More

How to compare two arrays to see how many same elements they have in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 457 Views

Let's say, we have two arrays, one contains the correct answer strings of some questions and one contains the answers attempted by a candidate, but somehow the arrays got shuffled and now they don't have answers in corresponding order. But we can be sure that no two questions had the same answers. Our job now is to write a function that takes these two arrays, checks them for common elements and finds all the common elements between them and then calculates the marks percentage of the candidate based on the count of common answers. Example const ...

Read More
Showing 4261–4270 of 8,010 articles
« Prev 1 425 426 427 428 429 801 Next »
Advertisements