
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
172 Views
We are required to write a JavaScript function that takes in an array of numbers that contains at least one duplicate pair of numbers.Our function should return the distance between all the duplicate pairs of numbers that exist in the array.The code for this will be −const arr = [2, ... Read More

AmitDiwan
191 Views
Suppose, we have a string that contains words separated by hyphens like this −const str = 'this-is-an-example';We are required to write a JavaScript function that takes in one such string and converts it into a camelCase string.For the above string, the output should be −const output = 'thisIsAnExample';The code for ... Read More

AmitDiwan
280 Views
We are required to write a JavaScript function that takes in an array of Numbers as the first argument and a Number as the second argument.The function should return an array of two numbers from the original array whose sum is closest to the number provided as the second argument.The ... Read More

AmitDiwan
456 Views
Suppose, we have an array of objects like this −const arr = [ {a:1, b:"apples"}, {a:3, b:"apples"}, {a:4, b:"apples"}, {a:1, b:"bananas"}, {a:3, b:"bananas"}, {a:5, b:"bananas"}, {a:6, b:"bananas"}, {a:3, b:"oranges"}, {a:5, b:"oranges"}, {a:6, b:"oranges"}, {a:10, b:"oranges"} ];We are required to ... Read More

AmitDiwan
241 Views
We are required to write a JavaScript function that takes in a two-dimensional array and returns its transposed array.The code for this will be −Method 1: Using Array.prototype.forEach()const arr = [ [0, 1], [2, 3], [4, 5] ]; const transpose = arr => { const ... Read More

AmitDiwan
220 Views
We are required to write a JavaScript function that takes in a hexadecimal color and returns its RGB representation.The function should return an object containing the respective values of red green and blue color −For example:hexToRgb('#0080C0') should return 0, 128, 192The code for this will be −const hex = '#0080C0'; ... Read More

AmitDiwan
329 Views
We are required to write a JavaScript function that takes in a RGB color and returns its hexadecimal representation.The function should take in an object containing three numbers representing the respective values of red green and blue color.For example:rgbToHex(0, 128, 192) should return '#0080C0'The code for this will be −const ... Read More

AmitDiwan
828 Views
Let’s say the following is our string with forward slash −var queryStringValue = "welcome/name/john/age/32"To replace before first forward slash, use replace() along with regular expressions.ExampleFollowing is the code −var regularExpression = /^[^/]+/ var queryStringValue = "welcome/name/john/age/32" var replacedValue = queryStringValue.replace(regularExpression, 'index'); console.log("Original value="+queryStringValue); console.log("After replacing the value="+replacedValue);To run the above ... Read More

AmitDiwan
425 Views
Let’s say the following is our object −const employeeDetails = [ { employeeName: "John Smith", employeeTechnology: "JavaScript HTML" }, { employeeName: "David Miller", employeeTechnology: "Java Angular" } ]You can use split() on the basis ... Read More

AmitDiwan
269 Views
Let’s say the following are our array elements −10, 20, 10, 50, 60, 10, 20, 40, 50To remove duplicate elements, use … new Set().ExampleFollowing is the code −var arrayWithNoDuplicateNumbers = [...new Set([10, 20, 10, 50, 60, 10, 20, 40, 50])]; console.log("No Duplicate values=") console.log(arrayWithNoDuplicateNumbers);To run the above program, use the ... Read More