
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
187 Views
For this, you need to use if condition to compare triplets.Let’s say we are passing the following values −35, 36, 37, 33, 48, 50ExampleFollowing is the code −function tripletsSolution(first, second, third, fourth, fifth, sixth) { var storedResult = [] if (first > fourth || second > fifth || ... Read More

AmitDiwan
465 Views
Let’s say we have the following hyphen delimited string with negative or range of numbers −var firstValue = "John-Smith-90-100-US"; var secondValue = "David-Miller--120-AUS";To split, use regular expressions. Following is the code −ExampleFollowing is the code −var firstValue = "John-Smith-90-100-US"; var secondValue = "David-Miller--120-AUS"; var regularExpression = /-(?=[A-Za-z-]|\d+-\d)/; var result1 = ... Read More

AmitDiwan
278 Views
There is no in-built function to replace all occurrences of word. You need to create your own function.Let’s say the following is our string −var sentence = "Yes, My Name is John Smith. I live in US. Yes, My Favourite Subject is JavaScript";ExampleFollowing is the code −var sentence = "Yes, My Name is John Smith. I live in US. Yes, My Favourite Subject is JavaScript"; console.log(sentence); ... Read More

AmitDiwan
387 Views
Let’s say the following is our string”var stringValue="453.000.00.00.0000";To convert the above string with zeroes to number, use parseInt() along with replace() −var numberValue = parseInt(stringValue.replace(/\./gm, '')); ExampleFollowing is the complete code −var stringValue="453.000.00.00.0000"; var numberValue = parseInt(stringValue.replace(/\./gm, '')); console.log("Original value="+stringValue) console.log("After modification the value="+numberValue);To run the above program, use the ... Read More

AmitDiwan
670 Views
The best way to reduce and merge a collection of objects, use the concept of Object.values() along with reduce().Following is the object −var details = [ { studentId: 10, marks: 75, studentName: "John" }, { studentId: 10, marks: 75, studentName: "John" }, { studentId: 11, marks: 98, ... Read More

AmitDiwan
480 Views
Let’s say the following are our time data −var startHour = dayjs().hour(10) var endHour = dayjs().hour(22)To get the difference, use the diff() method −ExampleFollowing is the code − Live Demo Document var startHour = dayjs().hour(10) var ... Read More

AmitDiwan
554 Views
Let’s say the following are ourrinput type checkbox −John David We want to check any of the checkbox. Use the checked property to check the checkbox.ExampleFollowing is the code − Live Demo Document John ... Read More

AmitDiwan
889 Views
Let’s say the following are our values −'6778922' '76633 56 1443' '8888 4532 3232 9999'We want the preceding characters to be replaced with 4 asterisks and the display rest of the last 3 characters. The output should be −**** 922 **** 443 **** 999For such conditions, use the replace() and ... Read More

AmitDiwan
8K+ Views
Let’s say the following is our string with comma and whitespace −var sentences = " John , David , Bob , Mike, Carol ";To split the sentences by comma, use split(). For removing surrounding spaces, ... Read More

AmitDiwan
212 Views
Let’s say the following is our array with duplicate elements −var duplicateNumbers = [10, 20, 100, 40, 20, 10, 100, 1000];We want the output to be −[10, 20, 100, 40, 1000];To display only the unique elements, use the concept of filter.ExampleFollowing is the code −var duplicateNumbers = [10, 20, 100, ... Read More