Convert URL Parameters to JSON in JavaScript

Pankaj Kumar Bind
Updated on 05-Nov-2024 11:11:41

2K+ Views

When working with URLs you will often encounter query parameters that add additional information to the base URL, it may be helpful for developers whenever they need to convert these URL parameters to JSON format, especially for reading and converting data. Here we will explore different methods to convert URL parameters to a JSON format in JavaScript including built in methods and custom solutions using splits, reduces, regular expressions. Understanding URL Parameters URL parameters follow ? character in a URL with each key-value pair separated by &, here’s an example URL. https://example.com/page?name=Pankaj&age=20&city=Surat In this URL name=Pankaj, age=20, ... Read More

Creating a Quiz Tool: A Complete Beginner's Guide

Naveen Kumawat
Updated on 05-Nov-2024 09:16:07

2K+ Views

We'll build a straightforward interactive quiz tool that allows users to answer questions, select their choices, and view their scores at the end. We'll accomplish this using HTML, CSS, and JavaScript. Guide to Building a Simple Quiz App Step 1 - Set Up Your HTML: First, create an index.html file to serve as the foundation for our quiz. This file will contain a container for displaying the quiz questions, answer options, and a submit button. Here’s a simple structure to get started. Step 2 - Style Your Quiz ... Read More

Generate Random Number from an Array in Java

karthikeya Boyini
Updated on 04-Nov-2024 18:44:53

5K+ Views

In this article, we will learn how to generate a random number from an array of integers in Java by using Random class. The Random class provides methods to generate random numbers, and we will use the nextInt(int bound) method to get a random index within the bounds of our array length. Problem Statement Given an array of integers, we need to randomly select and display one element from the array using Java. Input arr = { 10, 30, 45, 60, 78, 99, 120, 140, 180, 200}; Output Random number from the array = 30 Steps to generate ... Read More

Get Prime Numbers with BigInteger in Java

Nancy Den
Updated on 04-Nov-2024 18:44:41

625 Views

In this article, we will learn how to generate prime numbers using the BigInteger class in Java. A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. Here, we have the BigInteger type, which has operations for modular arithmetic, GCD calculation, primality testing, prime generation, etc. Steps to get the prime numbers with BigInteger type Following are the steps to get the prime numbers with BigInteger type − First, we will import the BigInteger from the java.math package. ... Read More

Find Last Index of a Particular Word in a String in Java

Shiva Keerthi
Updated on 04-Nov-2024 18:44:29

529 Views

In Java, a string is also an object. It is the object of the String class. A String is a sequence of characters. The last index of a particular word in a string is nothing but the position of the last occurrence of that word in the string. The index of a character in a string defines or tells the position in the string. The position or Index always starts from 0. In this section, we are going to discuss how to implement a Java program to find the last index of a particular word in a string. Strings are ... Read More

Subtract Week from Current Date in Java

Samual Sam
Updated on 04-Nov-2024 18:44:16

887 Views

In this article, we will learn to subtract the week from the current date using Java. This is useful when you need to manipulate dates, such as calculating dates from previous weeks for scheduling or tracking purposes. We'll use two approaches: using the Calendar class and the LocalDate class, showcasing how to easily adjust dates. Problem Statement Write a program in Java to subtract a specified number of weeks from the current date and display the updated date − Input Run the program Output Current Date = Mon Nov 04 09:41:18 IST 2024 Updated Date = Mon Oct 21 09:41:18 ... Read More

Convert Array into Collection in Java

AmitDiwan
Updated on 04-Nov-2024 18:44:02

827 Views

In this article, we will understand how to convert the array into a collection in Java. The Collection is a framework that provides an architecture to store and manipulate the group of objects. Java Collections can achieve all the operations that you perform on data such as searching, sorting, insertion, manipulation, and deletion. Problem Statement Write a program in Java to convert the array into the collection. Below is a demonstration of the same − Input Input array: [Java, Python, Scala, Shell] Output After elements after converting the array to a list ... Read More

Find Maximum of Three Numbers in Java

karthikeya Boyini
Updated on 04-Nov-2024 18:42:13

30K+ Views

In this article, we will learn how to find the maximum among three numbers using an if-else statement in Java. The if-else construct allows us to evaluate conditions and execute different blocks of code based on whether the conditions are true or false. We will check the values of three numbers to determine the largest by using comparison operators and control flow statements. Problem StatementGiven three integer values, write a Java program to find the maximum among them using if-else statements. Input num1 = 15, num2 = -5, num3 = 7 Output 15 is the maximum number. Steps to ... Read More

Java NumberFormat getInstance Method

Samual Sam
Updated on 04-Nov-2024 18:41:47

576 Views

In this article, we will learn how to format numbers in Java using the NumberFormat class from the java.text package. The NumberFormat class provides methods for formatting numbers based on Locale settings, which is useful for creating internationalized Java applications. Using the NumberFormat.getInstance() method, we can format double, int, or float values in a Java program.  Problem StatementGiven a decimal value, we need to format the number using Java's NumberFormat class to round it according to the default Locale settings.Input double val = 1.9898798; Output Formatted Value: 1.99 ... Read More

Difference Between git push origin and git push origin master

Moksh Gupta
Updated on 04-Nov-2024 13:37:19

1K+ Views

If you ever use Git while working on a project, one of the routine tasks you will encounter is always pushing code to a remote repository. The two commands that many developers, including those who are new to the git environment, find difficult to disentangle include git push origin and git push origin master. Though they look similar, these commands have distinct functions and use cases.In this article, we will look at the distinctions between these commands, when they can be applied, and how not to upset your team of programmers. Let’s dive in!1. Understanding git push origingit push origin are ... Read More

Advertisements