![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
Compare the Triplets - JavaScript?
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, 50
Example
Following is the code −
function tripletsSolution(first, second, third, fourth, fifth, sixth) { var storedResult = [] if (first > fourth || second > fifth || third > sixth) { storedResult = storedResult + 1; } if (first < fourth || second < fifth || third < sixth) { storedResult = storedResult + 1; } return storedResult.split(''); } console.log(tripletsSolution(35, 36, 37, 33, 48, 50));
To run the above program, use the following command −
node fileName.js.
Here, my file name is demo242.js.
Output
The output is as follows −
PS C:\Users\Amit\javascript-code> node demo242.js [ '1', '1' ]
Advertisements