AmitDiwan has Published 10744 Articles

Remove all whitespaces from string - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 10:01:47

252 Views

We are required to write a JavaScript function that takes in a string and returns a new string with all the character of the original string just the whitespaces removed.ExampleLet’s write the code for this function −const str = "This is an example string from which all whitespaces will be ... Read More

Implement divide & conquer logic in JavaScript to implement QuickSort

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:57:25

581 Views

We are required to write a JavaScript function that takes in an array of numbers and uses the quick sort algorithm to sort it.QuickSortThis algorithm is basically a divide and conquer algorithm where we pick a pivot in every pass of loop and put all the elements smaller than pivot ... Read More

Count total punctuations in a string - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:53:50

646 Views

In the English language, all these characters are considered as punctuations −'!', ", " ,"\'" ,";" ,"\"", ".", "-" ,"?"We are required to write a JavaScript function that takes in a string and count the number of appearances of these punctuations in the string and return that count.ExampleLet’s write the ... Read More

Equality of two 2-D arrays - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:51:57

375 Views

We are required to write a JavaScript function that takes in two 2-D arrays and returns a boolean based on the check whether the arrays are equal or not.The equality of these arrays, in our case, is determined by the equality of corresponding elementsBoth the arrays should have same number ... Read More

Transpose of a two-dimensional array - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:49:23

6K+ Views

TransposeThe transpose of a matrix (2-D array) is simply a flipped version of the original matrix (2-D array). We can transpose a matrix (2-D array) by switching its rows with its columns.Let’s say the following is our 2d array −const arr = [    [1, 1, 1],    [2, 2, ... Read More

Program to pick out duplicate only once - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:47:20

661 Views

We have an array of literals that contains some duplicate values appearing for many times like this −const arr = [1, 4, 3, 3, 1, 3, 2, 4, 2, 1, 4, 4];We are required to write a JavaScript function that takes in this array and pick out all the duplicate ... Read More

Check Disarium number - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:44:27

395 Views

Disarium Number − All those numbers which satisfy the following equation are dDisarium number −xy...z = x^1 + y^2 + ... + z^nWhere n is the number of digits in the number.For example −175 is a disarium number be: 175 = 1^1 + 7^2 + 5^3 = 1 + 49 ... Read More

Converting days into years months and weeks - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:42:20

3K+ Views

We are required to write a JavaScript function that takes in a number (representing the number of days) and returns an object with three properties, namely −weeks, months, years, daysAnd the properties should have proper values of these four properties that can be made from the number of days. We ... Read More

Armstrong numbers between a range - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:33:17

1K+ Views

A number is called Armstrong number if the following equation holds true for that number −xy..z = x^n + y^n+.....+ z^nWhere, n denotes the number of digits in the numberFor example − 370 is an Armstrong number because −3^3 + 7^3 + 0^3 = 27 + 343 + 0 = ... Read More

Calculate difference between circumference and area of a circle - JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Sep-2020 09:30:50

195 Views

Circumference of a circle is given by −pi * (r * r)And area of a circle is given by −2 * pi * rWhere r is the radius of the circle.We are required to write a JavaScript function that takes in the radius of circle and calculates the difference between ... Read More

Advertisements