इसके लिए, आपको ट्रिपलेट्स की तुलना करने के लिए if कंडीशन का उपयोग करना होगा।
मान लीजिए हम निम्नलिखित मान पास कर रहे हैं:
35, 36, 37, 33, 48, 50
उदाहरण
निम्नलिखित कोड देखें:
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));
उपरोक्त प्रोग्राम चलाने के लिए, निम्नलिखित कमांड का उपयोग करें:
node fileName.js.
यहां, मेरा फ़ाइल नाम demo242.js है।
आउटपुट
आउटपुट इस प्रकार है:
PS C:\Users\Amit\javascript-code> node demo242.js [ '1', '1' ]