AmitDiwan has Published 10740 Articles

Find distinct elements - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:27:48

154 Views

We are required to write a JavaScript function that takes in an array of literals, such that some array elements are repeated. We are required to return an array that contains that appear only once (not repeated).For example: If the array is:>const arr = [9, 5, 6, 8, 7, 7, ... Read More

Filtering out primes from an array - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:26:21

2K+ Views

We are required to write a JavaScript function that takes in the following array of numbers, const arr = [34, 56, 3, 56, 4, 343, 68, 56, 34, 87, 8, 45, 34];and returns a new filtered array that does not contain any prime number.ExampleFollowing is the code −const arr = ... Read More

Resolving or rejecting promises accordingly - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:25:16

125 Views

We are required to write a JavaScript function that imitates a network request, for that we can use the JavaScript setTimeout() function, that executes a task after a given time interval.Our function should return a promise that resolves when the request takes place successfully, otherwise it rejectsExampleFollowing is the code ... Read More

Frequency distribution of elements - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:22:50

1K+ Views

We are required to write a JavaScript function that contains the following string −const str = 'This string will be used to calculate frequency distribution';We need to return an object that represents the frequency distribution of various elements present in the array.ExampleFollowing is the code −const str = 'This string ... Read More

Finding mistakes in a string - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:21:38

511 Views

We are required to write a JavaScript function that takes in two strings. The first string is some mistyped string and the second string is the correct version of this sting. We can assume that the two strings we are getting as argument will always have the same length.We have ... Read More

Implementing Priority Sort in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:20:26

2K+ Views

We are required to write a JavaScript function that takes in two arrays of numbers, second being smaller in size than the first.Our function should be a sorted version of the first array (say in increasing order) but put all the elements that are common in both arrays to the ... Read More

Converting a proper fraction to mixed fraction - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:19:27

512 Views

Proper FractionA proper fraction is the one that exists in the p/q form (both p and q being natural numbers)Mixed FractionSuppose we divide the numerator of a fraction (say a) with its denominator (say b), to get quotient q and remainder r.The mixed fraction form for fraction (a/b) will be ... Read More

Reversing the prime length words - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:18:30

216 Views

We are required to write a JavaScript function that takes in a string that contains strings joined by whitespaces. Our function should create a new string that has all the words from the original string and the words whose length is a prime number reversed i.e. words with length 2, ... Read More

Temperature converter using JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:16:58

618 Views

We are required to write a JavaScript function that takes in a string representing a temperature either in Celsius or in Fahrenheit.Like this −"23F", "43C", "23F"We are required to write a JavaScript function that takes in this string and converts the temperature from Celsius to Fahrenheit and Fahrenheit to Celsius.ExampleFollowing ... Read More

Joining two strings with two words at a time - JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Sep-2020 09:14:35

184 Views

We are required to write a JavaScript function that takes in two strings, creates and returns a new string with first two words of first string, next two words of second string, then first, then second and so on.For example −If the strings are −const str1 = 'Hello world'; const ... Read More

Advertisements