- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9319 Articles for Object Oriented Programming
![Nikitasha Shrivastava](https://www.tutorialspoint.com/assets/profiles/655298/profile/60_3988199-1684213136.jpeg)
3K+ Views
In this problem we will understand how to get a single array from multiple arrays and different ways to solve this problem. We will use three methods to solve this problem: the first method is with the help of the spread operator, second concat method and finally last method using push with the spread operator. Understanding the problem We have given two or more arrays and we have to concatenate them in a single array. There can be many arrays given and after concatenating them it should appear as a single array. Let’s understand with ... Read More
![Nikitasha Shrivastava](https://www.tutorialspoint.com/assets/profiles/655298/profile/60_3988199-1684213136.jpeg)
778 Views
In the given problem, we have to find out the average of every group of n elements in the array. If there are m elements in the array, then calculate the average of every group and show the result in array form. Understanding the Problem Suppose we have 6 elements in the array and make a group of 2 elements. Now calculate the average of every group individually. Now that we have their average values, we can combine them into a single array. To implement this problem we have used reduce(), push(), and slice(). These ... Read More
![Nikitasha Shrivastava](https://www.tutorialspoint.com/assets/profiles/655298/profile/60_3988199-1684213136.jpeg)
2K+ Views
The problem is stating that we have to add two binary strings. Binary strings are a sequence of bytes. To add them in javascript, we will first convert them to decimal and calculate the sum. After adding those decimal numbers, we will convert it again into binary strings and print the output. What are Binary Strings? Binary numbers or binary strings are sequences of bytes in base 2. It is basically a combination of 0 and 1 to represent any number. While binary addition is one of the operations of mathematics to perform on binary strings. Binary addition ... Read More
![Nikitasha Shrivastava](https://www.tutorialspoint.com/assets/profiles/655298/profile/60_3988199-1684213136.jpeg)
332 Views
Merging the sorted arrays together in javascript can be done using the sorting techniques available in data structures. In this problem we will be given two sorted arrays and we have to merge them. After merging them, return a single array which is also in a sorted form. For solving this problem we will use greedy approach. What are Sorted Arrays ? In javascript arrays are the collection of similar data types and we can resize the array in run time. Sorted arrays are sequential forms of items of an array. Their order should be ... Read More
![Nikitasha Shrivastava](https://www.tutorialspoint.com/assets/profiles/655298/profile/60_3988199-1684213136.jpeg)
96 Views
In this problem we have to validate that a given number is a power of n. If the given number is power of n then it should return the true value of it otherwise it should return false. To check this kind of validation we generally use arithmetic operators like Modulus - %, Division - /, comparison operators like less than < or greater than >. Lets understand this problem with an example. True value: N = 27 So 33 = 27 False Value: N = 28 So 33 != ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
683 Views
Two strings (str1 and str2) are isomorphic if the characters in str1 can be replaced to get str2.For example −const str1 = 'abcde'; const str2 = 'eabdc';These two are an example of isomorphic stringsWe are required to write a JavaScript function that in two strings. The function should determine whether or not the two input strings are isomorphic.Exampleconst str1 = 'abcde'; const str2 = 'eabdc'; const isIsomorphic = (str1 = '', str2 = '') => { if (str1.length !== str2.length) { return false; }; for (let i = 0; i < str1.length; i++) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
372 Views
We are required to write a JavaScript function that takes in a number, say n, as the first and the only argument.The function should then return the count of all the prime numbers from 2 upto the number n.For example −For n = 10, the output should be: 4 (2, 3, 5, 7) For n = 1, the output should be: 0Exampleconst countPrimesUpto = (num = 1) => { if (num < 3) { return 0; }; let arr = new Array(num).fill(1); for (let i = 2; i * i < num; i++) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
361 Views
Given an integer n, we have to write a function that returns the number of trailing zeroes in n!.For example −trailingZeroes(4) = 0 trailingZeroes(5) = 1 because 5! = 120 trailingZeroes(6) = 1Exampleconst num = 17; const findTrailingZeroes = num => { let cur = 5, total = 0; while (cur
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Suppose, we have an array of objects like this −const arr = [ { "SupplierName" : "John", "Category " : "A", "Points" : 3 }, { "SupplierName" : "John", "Category " : "A", "Points" : 11 }, { "SupplierName" : "John", "Category " : "A", "Points" : undefined }, { "SupplierName" : "John", "Category " : "B", "Points" : 2 }, { "SupplierName" : "John", "Category " : "B", "Points" : 6 }, { "SupplierName" : "Praveen", "Category " : "A", "Points" : 3 }, { "SupplierName" : "Praveen", "Category " : "A", ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
506 Views
Suppose, we have an array of string dates like this −const arr = [ "2017-01-22 00:21:17.0", "2017-01-27 11:30:23.0", "2017-01-24 15:53:21.0", "2017-01-27 11:34:18.0", "2017-01-26 16:55:48.0", "2017-01-22 11:57:12.0", "2017-01-27 11:35:43.0" ];We are required to write a JavaScript function that takes in one such array. The function should find the oldest and the newest date from this array.And then the function should finally return an object containing those two dates.Exampleconst arr = [ "2017-01-22 00:21:17.0", "2017-01-27 11:30:23.0", "2017-01-24 15:53:21.0", "2017-01-27 11:34:18.0", "2017-01-26 16:55:48.0", "2017-01-22 11:57:12.0", "2017-01-27 11:35:43.0" ]; const ... Read More