比较三元组 - JavaScript?
javascriptweb developmentfront end technologyobject oriented programming更新于 2026/1/6 17:16:17
为此,您需要使用 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' ]
相关文章
有用资源
javascript 参考教程 - 该教程包含有关 javascript 的更多信息:https://www.cainiaomax.com/javascript/

