AmitDiwan has Published 10744 Articles

Group Similar Items in JSON in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 10:02:26

2K+ Views

Suppose, we have a JSON Array that contains data about some tickets like this −const arr = [    {       "quantity": "1",       "description": "VIP Ticket to Event"    },    {       "quantity": "1",       "description": "VIP Ticket to Event" ... Read More

Multiply and Sum Two Arrays in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 10:01:42

3K+ Views

We are required to write a JavaScript function that takes in two arrays of equal length. The function should multiply the corresponding (by index) values in each, and sum the results.For example: If the input arrays are −const arr1 = [2, 3, 4, 5]; const arr2 = [4, 3, 3, ... Read More

Split Array of items into N Arrays in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 10:00:37

841 Views

We are required to write a JavaScript function that splits an Array of numbers into N groups, which must be ordered from larger to smaller groups.For example, in the below code, split an Array of 12 numbers into 5 Arrays, and the result should be evenly split, from large (group) ... Read More

Evaluating a string as a mathematical expression in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:59:34

3K+ Views

We are required to write a JavaScript function that takes in a stringified mathematical equation. The function should return the result of the equation provided to the function.For example: If the equation is −const str = '1+23+4+5-30';Then the output should be 3ExampleThe code for this will be −const str = ... Read More

Separating digits of a number in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:59:13

1K+ Views

We are required to write a JavaScript program that provides user with a input. When the user inputs some value and press the button, our function should check if the input is a valid number, if it is a valid number, the program should print all digits of the number ... Read More

Number to alphabets in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:59:09

832 Views

We are required to write a JavaScript function that takes in a string of any variable length that represents a number.Our function is supposed to convert the number string to the corresponding letter string.For example − If the number string is −const str = '78956';Then the output should be −const ... Read More

JavaScript: Sort Object of Objects

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:57:55

2K+ Views

Suppose we have an Object of Objects like this −const obj = {    "CAB": {       name: 'CBSSP',       position: 2    },    "NSG": {       name: 'NNSSP',       position: 3    },    "EQU": {       name: ... Read More

Search by id and remove object from JSON array in JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:55:56

3K+ Views

Suppose, we have an array of objects that contains data about some movies like this −const arr = [    {id: "1", name: "Snatch", type: "crime"},    {id: "2", name: "Witches of Eastwick", type: "comedy"},    {id: "3", name: "X-Men", type: "action"},    {id: "4", name: "Ordinary People", type: "drama"}, ... Read More

List all duplicate values in a nested JavaScript object

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 09:54:16

1K+ Views

Suppose, we have a nested object that contains data about some pets like this −const pets = {    owner1: 'Frank',    owner2: 'Curly',    owner3: 'Maurice',    dogs: {       terriers: {          name1: 'Fido',          name2: 'Woofy',       ... Read More

JavaScript - Find keys for the matched values as like query in SQL

AmitDiwan

AmitDiwan

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

396 Views

Suppose, we have an object like this −const obj = {"100":"Jaipur", "101":"Delhi", "102":"Raipur", "104":"Goa"};We are required to write a JavaScript function that takes in one such object as the first argument and a search query term as the second argument. Then our function should return all those key/value pairs whose ... Read More

Advertisements