Compare the Triplets - JavaScript?

JavascriptWeb DevelopmentFront End TechnologyObject Oriented Programming

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' ]
raja
Updated on 03-Oct-2020 15:30:31

Advertisements