Revathi Satya Kondra

Revathi Satya Kondra

Technical Content Writer, Tutorialspoint

65 Articles Published

Articles by Revathi Satya Kondra

Page 5 of 7

Converting seconds in years days hours and minutes in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 10-Feb-2025 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 − Sample Input ...

Read More

Converting array to phone number string in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 30-Jan-2025 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 us understand through ...

Read More

Converting any case to camelCase in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 30-Jan-2025 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 case to camelCase in JavaScript is quite easy. Let's ...

Read More

Appending Suffix to Numbers in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 30-Jan-2025 1K+ Views

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. The task of our function is to ...

Read More

Filter array with filter() and includes() in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 28-Jan-2025 14K+ Views

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 suppose 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 the clear idea about the filter() and includes() in JavaScript. Let's discuss individually. JavaScript filter() and includes() Methods filter(): It is used to create a new array that includes only the elements that satisfy the condition provided by the callback function. includes(): Using includes(), the callback ...

Read More

Static methods vs Instance methods in Java

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 28-Jan-2025 3K+ Views

In Java, the behaviour of any variable or method is defined by the keyword used in front of its declaration. One of the non-access modifiers is static, which can be used with both methods and variables. The static methods are defined at the class level and can be accessed without creating an instance of the class, while instance methods require an object of the class for accessibility. Static methods exist as a single copy for the entire class, whereas instance methods exist as multiple copies, depending on the number of instances created for that particular class. Static methods cannot directly ...

Read More

Java Math subtractExact(long x, long y) method

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 28-Jan-2025 554 Views

We will discuss the Java Math subtractExact(long x, long y) method in Java and understand its functionalities and working. The subtractExact()is an inbuilt function in the Java Math library. The function returns the difference between the two parameters passed as arguments in the function. The function returns an exception when the returned value overflows the range of values of a particular data type. It is the most commonly used class for mathematical operations is the java.lang.Math class is a part of the Java Standard Library and is included in the java.lang package. Syntax Following is the syntax of the subtractExact() function ...

Read More

Java program to find the length of the Longest Consecutive 1’s in Binary Representation of a given integer

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 28-Jan-2025 514 Views

The length of the longest consecutive 1s in the binary representation of a given integer involves converting the integer to its binary form and then identifying the longest run of contiguous 1s. Here, we can represent each integer in binary as a series of 0s and 1s. Bitwise operations allow efficient bit manipulation, making it easy to count and update the longest sequence of consecutive 1s. Consider special cases such as when the integer is 0 (binary representation 0) or when it contains only 1s (e.g., for the number 7, binary 111). To understand the concept clearly, Let's go through ...

Read More

What is Runnable interface in Java?

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 17-Jan-2025 2K+ Views

An interface is like a reference type, similar to a class that enforces the rules that the class must implements(It is a keyword). An interface may have abstract methods i.e. methods without a definition and also constants or variables with fixed value. What is a Runnable interface in Java? If your class is intended to be executed as a thread, then you can achieve this by implementing a Runnable interface. This belongs to the java.lang package. The Runnable interface in Java is a functional interface that enables the compiled code of the class to run as a separate thread. The ...

Read More

Java Program to return a Date set to noon to the closest possible millisecond of the day

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 14-Jan-2025 397 Views

To set a Date object to noon to the closest possible millisecond of the day, we will make sure that the hour is set to noon, and both the minutes, seconds, and milliseconds are set to zero. This precise setting can be achieved using the Calendar class in Java. By setting these specific fields, we can ensure that the time is 12:00:00.000 PM, providing the closest possible millisecond representation of noon. Returning a date set to noon to the closest possible millisecond of the day in Java is quite easy. Let's learn the following ways: ...

Read More
Showing 41–50 of 65 articles
« Prev 1 3 4 5 6 7 Next »
Advertisements