Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Revathi Satya Kondra
65 articles
Converting array to phone number string in JavaScript
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 MoreAppending Suffix to Numbers in JavaScript
Appending suffixes to numbers in JavaScript is used to add ordinal indicators (like "st", "nd", "rd", and "th") to the end of a number to denote its position in a sequence. This is useful for displaying dates, rankings, or other numeric data. A custom function can be created to append the correct suffix to a given number. The function handles special cases for numbers ending in 11, 12, and 13, and applies the appropriate suffix based on the last digit for other numbers. Rules for Ordinal Suffixes ...
Read MoreConverting any case to camelCase in JavaScript
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 MoreConverting seconds in years days hours and minutes in JavaScript
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 MoreFilter array with filter() and includes() in JavaScript
In this article, using the filter() and includes() methods in JavaScript, we can filter an array based on the elements presence in another array or specific conditions. For example, if we have two arrays as array1 and array2, we want to filter array1 to include only the elements that are present in array2. To have a clear idea about the filter() and includes() methods in JavaScript, let's discuss them individually. JavaScript filter() and includes() Methods filter(): Creates a new array that includes only the elements that satisfy the condition provided by the callback function. includes(): ...
Read MoreHow do I remove a particular element from an array in JavaScript
In JavaScript, removing a particular element from an array refers to the process of deleting or filtering out a specific element so that it no longer exists within that array. Arrays are the most commonly used data structures in JavaScript, allowing developers to store and manipulate collections of items. There are several methods to remove elements from arrays, each with different behaviors and use cases. Method 1: Using splice() Method The splice() method modifies the original array by removing elements at a specified index. Syntax array.splice(index, deleteCount[, element1[, element2[, ...]]]) Parameters ...
Read MoreHow does “void *” differ in C and C++?
Both C and C++ support void pointers, but their behavior differs significantly. In C, a void pointer can be directly assigned to any other pointer type without explicit typecasting. However, in C++, assigning a void pointer to any other pointer type requires an explicit typecast. Syntax void *pointer_name; Void Pointer in C A void pointer (also called a generic pointer) in C is a special type of pointer that can point to any data type, but doesn't have any type by itself. It can hold the address of any variable (int, float, char, etc.). ...
Read MoreCan we use function on left side of an expression in C and C++?
In C and C++, you normally cannot use a function call on the left side of an assignment if it returns a value by copy, because function calls return non-assignable temporary values. However, there are specific cases where this is possible − Syntax // Invalid - function returns value by copy function_name() = value; // Compiler error // Valid - function returns pointer (C) *function_name() = value; // Dereference pointer // Valid - function returns reference (C++ only) function_name() = value; ...
Read MoreLine Splicing in C/C++
In C programming, line splicing is a preprocessor feature that allows you to split one long line of code into multiple lines by using a backslash (\) at the end of a line. The backslash tells the preprocessor to treat the next line as a continuation of the current line. Line splicing is processed before compilation during the preprocessing phase. It does not have parameters or return values − it simply affects how lines of code are interpreted by joining them together. Syntax line_of_code \ continuation_of_line The backslash must be the last character on ...
Read MoreHow can I get the list of files in a directory using C or C++?
Listing files in a directory is used to write a program that opens a specified folder (e.g: "/myfiles"), reads its contents, and displays the names of each file and subfolder one by one. In C, to see all the files in a directory, you can use special system functions that let you read the directory's contents. In real life, we open folder to see the contents inside the files. Similarly, in C, we can write a program to display all the files and folders in a directory. Syntax DIR *opendir(const char *dirname); struct dirent *readdir(DIR ...
Read More