mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 16:56:15 -04:00
Use reduce to find smallest and largest inputNums.
Tab shadows are now displayed using css classes
This commit is contained in:
parent
b3fa1eaae2
commit
30a66f1441
3 changed files with 24 additions and 27 deletions
|
@ -315,13 +315,10 @@ self.getInputProgress = function(inputNum) {
|
|||
* @returns {number}
|
||||
*/
|
||||
self.getLargestInputNum = function(inputNums) {
|
||||
let max = -1;
|
||||
for (let i = 0; i < inputNums.length; i++) {
|
||||
// Object.keys() returns a string array, so parseInt here
|
||||
const num = parseInt(inputNums[i], 10);
|
||||
if (num > max) max = num;
|
||||
}
|
||||
return max;
|
||||
return inputNums.reduce((acc, val) => {
|
||||
val = parseInt(val, 10);
|
||||
return val > acc ? val : acc;
|
||||
}, -1);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -331,11 +328,10 @@ self.getLargestInputNum = function(inputNums) {
|
|||
* @returns {number}
|
||||
*/
|
||||
self.getSmallestInputNum = function(inputNums) {
|
||||
let min = Number.MAX_SAFE_INTEGER;
|
||||
for (let i = 0; i < inputNums.length; i++) {
|
||||
const num = parseInt(inputNums[i], 10);
|
||||
if (num < min) min = num;
|
||||
}
|
||||
const min = inputNums.reduce((acc, val) => {
|
||||
val = parseInt(val, 10);
|
||||
return val < acc ? val : acc;
|
||||
}, Number.MAX_SAFE_INTEGER);
|
||||
|
||||
// Assume we don't have this many tabs!
|
||||
if (min === Number.MAX_SAFE_INTEGER) return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue