比较三元组 - JavaScript?
为此,你需要使用 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' ]
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP