AmitDiwan has Published 10740 Articles

How to do multidimensional array intersection using JavaScript?

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:13:40

440 Views

We are required to write a JavaScript function that takes in a multidimensional array of arrays of literal values. Our function should return the intersecting array of all the subarrays present in the input array.ExampleThe code for this will be −const arr = [    ["garden", "canons", "philips", "universal"],   ... Read More

How to dynamically combine all provided arrays using JavaScript?

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:12:33

485 Views

Suppose we have two arrays of literals like these −const arr1= ['a', 'b', 'c']; const arr2= ['d', 'e', 'f'];We are required to write a JavaScript function that takes in two such arrays and build all possible combinations from the arrays.So, for these two arrays, the output should look like −const ... Read More

Sort array by month-year JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:11:10

738 Views

Suppose, we have an array that contains dates in MM-YYYY format like this −const arr = ["1-2016", "7-2015", "7-2016", "3-2016", "8-2016", "2-2016", "6-2016", "8-2015", "5-2016", "4-2016", "9-2015", "10-2015", "11-2015", "12-2015"];We are required to write a JavaScript function that takes in one such array and sorts it such that the dates ... Read More

Find the most frequent number in the array and how many times it is repeated in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:09:48

288 Views

We are required to write a JavaScript function that takes in an array of literals and finds the most frequent number in the array and how many times it is repeated.ExampleThe code for this will be −const arr = ['13', '4', '1', '1', '4', '2', '3', '4', '4', '1', '2', ... Read More

JavaScript - Determine all possible ways a group of values can be removed from a sequence

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:08:22

126 Views

We are required to write a JavaScript function that determines how many different ways we can remove a group of values from a sequence, leaving the original sequence in order (stable), and making sure to remove only one instance value each from the original sequence.For example − If the sequence ... Read More

Filter nested object by keys using JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:06:07

1K+ Views

Suppose, we have an array of objects like this −const arr = [{ 'title': 'Hey',    'foo': 2,    'bar': 3 }, {    'title': 'Sup',    'foo': 3,    'bar': 4 }, {    'title': 'Remove',    'foo': 3,    'bar': 4 }];We are required to write a JavaScript ... Read More

Convert array with duplicate values to object with number of repeated occurrences in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:04:40

745 Views

Suppose, we have an array string that contains some duplicate entries like this −const arr = ['California', 'Texas', 'Texas', 'Texas', 'New York', 'Missouri', 'New Mexico', 'California'];We are required to write a JavaScript function that takes in one such array. Our function should then construct an array of objects that contains ... Read More

Search from an array of objects via array of string to get array of objects in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:02:57

387 Views

Suppose, we have one array of strings and another array of objects like this −const arr1 = [ '1956888670', '2109171907', '298845084' ]; const arr2 = [    { KEY: '1262875245', VALUE: 'Vijay Kumar Verma' },    { KEY: '1956888670', VALUE: 'Sivakesava Nallam' },    { KEY: '2109171907', VALUE: 'udm analyst' ... Read More

Convert the number or boolean type JSON object from string type to its original in JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 10:01:48

1K+ Views

Suppose we have a short JSON object like this −const obj = {"name":"sam", "age":"24", "isMarried":"false"};Here, some of the Number and Boolean values, by mistake, have been coerced to String.Like the age property which was a Number and isMarried property which was a boolean. Our job is to write a function ... Read More

Determining isomorphic strings JavaScript

AmitDiwan

AmitDiwan

Updated on 23-Nov-2020 07:08:50

810 Views

Two strings (str1 and str2) are isomorphic if the characters in str1 can be replaced to get str2.For example −const str1 = 'abcde'; const str2 = 'eabdc';These two are an example of isomorphic stringsWe are required to write a JavaScript function that in two strings. The function should determine whether ... Read More

Advertisements