AmitDiwan has Published 10744 Articles

JavaScript: Combine highest key values of multiple arrays into a single array

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:51:25

235 Views

We are required to write a JavaScript function that takes in any number of array of Numbers. Our function should return an array of greatest numbers picked from the input array of array. The number of elements in the output array should be equal to the number of subarrays contained ... Read More

Sorting parts of array separately in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:50:22

209 Views

We have an array that contains many objects. We are required to write a function to sort the first half of the array in ascending order.And the second half of the array with ascending order to but without inter mixing the entries of halves into one another.Consider this sample array ... Read More

Splitting an object into an array of objects in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:49:07

3K+ Views

Suppose, we have an object like this −const obj = {    "value 0": "value",    "value 1": "value",    "value 2": "value",    "value 3": "value",    "value 4": "value",    "value 5": "value",    "value 6": "value",    "value 7": "value",    "value 8": "value",    "value 9": ... Read More

Get the total number of same objects in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:47:49

143 Views

Suppose, we have an array of objects describing the routes of some flights like this −const routes = [    {       flyFrom: "CDG",       flyTo: "DUB",       return: 0,    },    {       flyFrom: "DUB",       flyTo: "SXF", ... Read More

How to find a nearest higher number from a specific set of numbers: JavaScript ?

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:45:48

151 Views

We have a set of numbers and our requirement is to find the same or the nearest higher number key to a specific number provided as the input to the function.The set of numbers is defined as −const numbers = {    A:107,    B:112,    C:117,    D:127,   ... Read More

How to create every combination possible for the contents of two arrays in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:45:46

2K+ Views

Suppose we have two arrays of literals like this −const arr1 = ["A", "B", "C"]; const arr2 = ["1", "2", "3"];We are required to write a JavaScript function that takes in two such arrays of literals. The function should then combine each element of the first array with each element ... Read More

Generating combinations from n arrays with m elements in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:44:37

762 Views

We are required to write a JavaScript function that generates combinations from n number of arrays with m number of elements in them.For example −Consider this data −const arr = [    [0, 1],    [0, 1, 2, 3],    [0, 1, 2] ]3 sub arrays, with a different number ... Read More

How to concatenate two JavaScript objects with plain JavaScript ?

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:43:33

357 Views

Suppose we have two objects defined like this −const obj1 = {    id1: 21,    name1: "Kailash" }; const obj2 = {    id2: 20,    name2: "Shankar" };We are required to write a JavaScript function that takes in two such objects and merges into a single object.In other ... Read More

Remove duplicates from array with URL values in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:43:10

435 Views

Suppose, we have an array of objects like this −const arr = [    {       url: 'www.example.com/hello',       id: "22"    },    {       url: 'www.example.com/hello',       id: "22"    },    {       url: 'www.example.com/hello-how-are-you',     ... Read More

Compare keys & values in a JSON object when one object has extra keys in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:41:17

2K+ Views

Suppose, we have two JSON objects like these −const obj1 = {a: "apple", b: "banana", c: "carrot"}; const obj2 = {a: "apple", e: "egg", b: "banana", c: "carrot", d: "dog"};We are required to write a JavaScript function that takes in two such objects. We want to be able to have ... Read More

Advertisements