AmitDiwan has Published 10744 Articles

Capitalize letter in a string in order and create an array to store - JavaScript

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:22:49

119 Views

We are required to write a JavaScript function that takes in a string and turns it into a Mexican Wave i.e. resembling string produced by successive captial letters in every word −For example −If the string is −const str = 'edabit';Then the output should be the following i.e. successive single ... Read More

Sorting an array of objects by property values - JavaScript

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:21:20

389 Views

Suppose, we have an array of objects like this −const homes = [    {        "h_id": "3",        "city": "Dallas",        "state": "TX",        "zip": "75201",        "price": "162500"    }, {        "h_id": "4",     ... Read More

Finding the length of a JavaScript object

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:19:54

215 Views

Suppose we have an object like this −const obj = {    name: "Ramesh",    age: 34,    occupation: "HR Manager",    address: "Tilak Nagar, New Delhi",    experience: 13 };We are required to write a JavaScript function on Objects that computes their size (i.e., the number of properties in ... Read More

How do we remove a property from a JavaScript object? - JavaScript

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:18:51

299 Views

Let’s say, we have an object as follows −const myObject = {    "ircEvent": "PRIVMSG",    "method": "newURI",    "regex": "^http://.*" };We are required to illustrate the best way to remove the property regex to end up with new myObject?Following is the solution −const myObject = {    "ircEvent": "PRIVMSG", ... Read More

Validating email and password - JavaScript

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:16:38

2K+ Views

Suppose, we have this dummy array that contains the login info of two of many users of a social networking platform −const array = [{    email: 'usman@gmail.com',    password: '123'  },  {    email: 'ali@gmail.com',    password: '123'  } ];We are required to write a JavaScript function that takes ... Read More

The Zombie Apocalypse case study - JavaScript

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:15:03

262 Views

A nasty zombie virus is spreading out in the digital cities. We work at the digital CDC and our job is to look over the city maps and tell which areas are contaminated by the zombie virus so the digital army would know where to drop the bombs.They are the ... Read More

Filter one array with another array - JavaScript

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:13:02

342 Views

Suppose, we have an array and objects like the following −const main = [    {name: "Karan", age: 34},    {name: "Aayush", age: 24},    {name: "Ameesh", age: 23},    {name: "Joy", age: 33},    {name: "Siddarth", age: 43},    {name: "Nakul", age: 31},    {name: "Anmol", age: 21}, ]; ... Read More

How to insert an element into all positions in an array using recursion - JavaScript?

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:11:02

527 Views

We are required to declare a function, let’s say insertAllPositions, which takes two arguments −an element, x, and an array, arr. Functions must return an array of arrays, with each array corresponding to arr with x inserted in a possible position.That is, if arr is the length N, then the ... Read More

How to return object from an array with highest key values along with name - JavaScript?

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:09:18

702 Views

Suppose, we have an array of objects that contains information about marks of some students in a test −const students = [    { name: 'Andy', total: 40 },    { name: 'Seric', total: 50 },    { name: 'Stephen', total: 85 },    { name: 'David', total: 30 }, ... Read More

How can we make an Array of Objects from n properties of n arrays in JavaScript?

AmitDiwan

AmitDiwan

Updated on 01-Oct-2020 10:07:00

171 Views

Suppose we have two arrays of literals like these −const options = ['A', 'B', 'C', 'D']; const values = [true, false, false, false];We are required to write a JavaScript function that creates and returns a new Array of Objects from these two arrays, like this −const response = [   ... Read More

Advertisements