Found 10710 Articles for Web Development

Difference Between XML and HTML

AmitDiwan
Updated on 21-Dec-2021 07:38:09

630 Views

In this post, we will understand the difference between HTML and XML.HTMLIt refers to Hyper Text Markup Language.It helps create web pages and applications.It is a markup language.It helps create static pages as well.It helps display data.It doesn’t transport data.HyperText helps define link between multiple web pages.Markup Language helps define text document using tags, which gives a structure to the web page.It helps annotate the text so that a system can understand it and use it.It ignores minor errors.It is not case sensitive.There are specific number of tags in HTML.These tags are predefined.It doesn’t preserve white spaces.Closing tags are not ... Read More

Super Ugly Numbers JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:46:18

123 Views

Super Ugly NumberSuper ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13, 14, 16, 19, 26, 28, 32] is the sequence of the first 12 super ugly numbers given primes = [2, 7, 13, 19] of size 4.ProblemWe are required to write a JavaScript function that takes in number, num, as the first argument and an array, arr, of prime numbers as the second argument. The function should find and return the (num)th super ugly number.ExampleThe code for this will be −const ... Read More

Counting smaller numbers after corresponding numbers in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:43:50

137 Views

ProblemWe are required to write a JavaScript function that takes in an array of Numbers as the first and the only argument.Our function should prepare a new array based on the input array. And each corresponding element of this new array should be the count of elements smaller than the corresponding element in the original array.For example, if the input to the function is −const arr = [4, 7, 1, 4, 7, 5, 3, 8, 9];Then the output should be −const output = [2, 4, 0, 1, 2, 1, 0, 0, 0];Output Explanation:Because number smaller than 4 to its right ... Read More

Limiting duplicate character occurrence to once in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:42:10

122 Views

ProblemWe are required to write a JavaScript function that takes in a string, str, as the only argument.The function should prepare a new string based on the input string in which the only one appearance of each character is kept and the character kept is the one which makes the result string lexicographically the smallest.For example, if the input to the function is −const str = 'cbacdcbc';Then the output should be −const output = 'acdb';Output Explanation:Note that we could have removed any occurrence of ‘c’ from the string but we removed the very first, which makes the string lexicographically the ... Read More

Maximum length product of unique words in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:39:40

77 Views

ProblemWe are required to write a JavaScript function that takes in an array of strings (only lowercase string alphabets) as the first and the only argument.The function should pick two such strings from the array that shares no common characters and have the maximum product of their lengths. And then our function should return the length product of two such strings. If there exist no such strings in the array, we should return 0.For example, if the input to the function is −const arr = ["karl", "n", "the", "car", "mint", "alpha"];Then the output should be −const output = 20;Output Explanation:The ... Read More

Switching on and off bulb in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:37:36

490 Views

ProblemConsider this following situation −There are n bulbs that are initially off. We first turn on all the bulbs. Then, we turn off every second bulb. On the third round, we toggle every third bulb (turning on if it's off or turning off if it's on).In general, for the ith round, we toggle every i bulb. And lastly for the nth round, we only toggle the last bulb.We are required to write a JavaScript function that takes n as the only input and finds out how many bulbs are on after n rounds.For example, if the input to the function ... Read More

Finding maximum number from two arrays in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:35:27

506 Views

ProblemWe are required to write a JavaScript function that takes in two arrays of single digit numbers representing two numbers, arr1 and arr2 as the first and second argument. The third argument to the function will be a number, num (num {    const map = new Map();    const match = (a, b, num) => {       if (map.has(a + ', ' + b + ', ' + num)) {          return map.get(a + ', ' + b + ', ' + num);       }       let output = ... Read More

Summing up to amount with fewest coins in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:31:46

116 Views

ProblemWe are required to write a JavaScript function that takes in arr, arr, as the first argument. This array basically specifies the different types of coin denominations we have.The second argument to the function is a number, amount, which specifies the amount we want to add up to. Our function should simply return the minimum number of coins required to add up to that amount.If we can, in no way, reach amount, we should return -1.For example, if the input to the function is −const arr = [1, 2, 5]; const amount = 17;Then the output should be −const output ... Read More

Uneven sorting of array in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:29:41

140 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the only argument. Our function should sort this array in such a way that after sorting, the elements should follow this pattern −arr[0] < arr[1] > arr[2] < arr[3]....For example, if the input to the function is −const arr = [1, 5, 1, 1, 6, 4];Then the output can (there can be more than one possible answer as well) be −const output = [2, 3, 1, 3, 1, 2];ExampleThe code for this will be −const arr = [1, 5, 1, 1, 6, 4]; ... Read More

Validate URL in ReactJS

Rahul Bansal
Updated on 19-Mar-2021 11:15:50

2K+ Views

In this article, we are going to see how to validate a URL (Uniform Resource Locator) in a React application.To validate a URL, we are going to install a third-party package of ‘validator’ which is used to validate the URL. Example of a valid and an invalid URL are as follows −Valid URL − https://www.tutorialspoint.com/Invalid URL − https://www.tutorialspointInstalling the modulenpm install validatorORyarn add validatorNpm is the node package manager which manages our React package but yarn is the more secure, faster and lightweight package manager.ExampleIn this example, we will build a React application which takes a URL input from the ... Read More

Advertisements