Front End Technology Articles

Page 320 of 652

Converting any case to camelCase in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 15-Mar-2026 1K+ Views

In this article, we create a function that can take a string in any format. Such as normal case, snake case, pascal case or any other into camelCase in JavaScript. camelCase is a writing style where each word within a phrase is capitalized, except for the first word, and there are no spaces or punctuation. Let us understand through some sample example of I/O Scenario − Sample Input - const str = 'New STRING'; Sample Output - const output = 'newString'; Converting any case to camelCase in JavaScript Converting any ...

Read More

Converting array to phone number string in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 15-Mar-2026 1K+ Views

To convert an array to a phone number string in JavaScript can be done by formatting the array elements into the desired phone number pattern. Following are the steps to learn how to convert array to phone number string in Javascript − Ensure that the array has the correct number of elements (usually 10 for a standard phone number). Join the elements of the array into a single string. Format the string into the desired phone number pattern, such as (XXX) XXX-XXXX. Let ...

Read More

Converting seconds in years days hours and minutes in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 15-Mar-2026 2K+ Views

In this article, we create a function that takes in a number(num) which represents the number of seconds. So, it construct and return a string that contains information of years, days, hours and minutes contained in those seconds. Converting seconds into years, days, hours, and minutes in JavaScript involves breaking down a given total of seconds into more understandable time units. This process helps display elapsed time in a readable format. For the purpose of the article, we will consider that all the years have 365 days. Let us understand through some sample example of I/O Scenario ...

Read More

JavaScript - Check if value is a percentage?

Disha Verma
Disha Verma
Updated on 15-Mar-2026 1K+ Views

To check the value for percentage, use a regular expression. When dealing with user input or processing data in JavaScript, it's important to make sure a value is a valid percentage. This article shows you how to check if a value is a percentage using JavaScript, highlighting a useful method that involves regular expressions. Let's say the following is our value: var value = "97%"; To check the value for percentage, we are using a regular expression that matches numbers followed by the % symbol. Using Regular Expression The best way to check ...

Read More

JavaScript: How to filter out Non-Unique Values from an Array?

Disha Verma
Disha Verma
Updated on 15-Mar-2026 1K+ Views

To filter out non-unique values from an array in JavaScript, you can use the filter() method, a for loop, the Set and filter() method, and the reduce() method. In this article, we will filter out non-unique values and return an array that only contains unique non-repeating elements. Arrays are data structures used to store data in a structured format. We can store the data in an array and retrieve them using their indexes. These indexes serve as a key for these values. Table of Content Filtering non-unique values from an array can be done in the following ways: ...

Read More

JavaScript: How to map array values without using \"map\" method?

Disha Verma
Disha Verma
Updated on 15-Mar-2026 2K+ Views

When you need to transform array elements without using the built-in map() method, JavaScript provides several alternatives. These approaches manually iterate through arrays and apply transformations to create new arrays with modified values. Table of Contents You can map array values without using the map method in the following ways: Using forEach() Using reduce() Using a for Loop Using while Loop Using forEach() The forEach() method iterates through each array element, allowing you to apply transformations while manually building a ...

Read More

JavaScript input type=submit is not working?

Disha Verma
Disha Verma
Updated on 15-Mar-2026 2K+ Views

The input type submit is not working is one of the common issues that developers face while working with JavaScript forms. To make it work properly, you need to handle form events correctly or prevent the default browser behavior when necessary. This article examines common reasons why a submit button might not work in JavaScript and provides practical solutions to resolve these issues. Common Reasons for Submit Button Issues The following are some common reasons that may lead to this issue: Missing Event Listener − If you haven't added an event ...

Read More

JavaScript Sum of two objects with same properties

Disha Verma
Disha Verma
Updated on 15-Mar-2026 2K+ Views

In JavaScript, summing two objects with identical properties is a common task when working with data aggregation. This involves creating a new object where each property's value is the sum of corresponding values from the input objects. In JavaScript, objects are data structures that store key-value pairs. When you have multiple objects with the same property names, you often need to combine their values mathematically. Understanding the Problem When you have two objects with the same property names, the goal is to create a new object where each property's value is the sum of the matching values ...

Read More

JavaScript: Computing the average of an array after mapping each element to a value

Disha Verma
Disha Verma
Updated on 15-Mar-2026 995 Views

Computing the average of an array after mapping each element to a value in JavaScript can be done using several approaches including the forEach() loop, parseInt() method, reduce() method, and for...of loop. This article demonstrates how to calculate the average by summing all array elements and dividing by the array length. Given below are examples of arrays where we compute the average by summing values and dividing by the number of elements: Input: [1, 2, 3, 4, 5] Result: 3 Explanation: (1+2+3+4+5)/5 = 3 Input: [2, 4, 7, 9, 1, 3, 8] Result: 4.857142857142857 Explanation: (2+4+7+9+1+3+8)/7 ...

Read More

JavaScript union of two objects

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 785 Views

In this article, we will learn to calculate the union of two objects in JavaScript. The union of two objects results in a new object that contains all the properties of both objects. What is the Union of Two Objects? The union of two objects is the process of combining the properties of both objects into a single object. When properties have the same key, their values are merged together. For example Input − const obj1 = { name: "John", email: "john@email.com" }; const obj2 = { name: "Jane", email: "jane@email.com" }; ...

Read More
Showing 3191–3200 of 6,519 articles
« Prev 1 318 319 320 321 322 652 Next »
Advertisements