DarkteK

Gonza's test - Disk Space Analysis

Mar 29th, 2022
1,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Gonza's test - Disk Space Analysis.
  2. const n = 3 // The length of segments.
  3. const space = [2, 5, 4, 6, 8];
  4. const x = 5 // The length of analysis segments (Size of space).
  5.  
  6. function functionTest(n, space) {
  7.   let segmentList = [];
  8.  
  9.   for (let i = 0; i < n; i++) {
  10.     let tempArray = [];
  11.     let tempIndex = i;
  12.     for (let o = 0; o < n; o++) {
  13.       tempArray.push(space[tempIndex]);
  14.       tempIndex++;
  15.     }
  16.     // We obtain the minimum value from the previous array.
  17.     segmentList.push(Math.min(...tempArray));
  18.   }
  19.  
  20.   // Return the max value from the previous minimum values.
  21.   let maxValue = Math.max(...segmentList);
  22.  
  23.   return maxValue;
  24. }
  25.  
  26. console.info(functionTest(n, space));
Advertisement
Add Comment
Please, Sign In to add comment