इसके लिए, आपको ट्रिपल की तुलना करने के लिए 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' ]