How to generate non-repetitive intervals by js

for example, define a range from 1 to 100

randomly generate 20-50, 60-80, etc. The range in order cannot be superimposed

something like this

randomly generate a range of 1-100

[[6jue 9], [22jue 62], [40jue 23], [74jue 62], [76jue 97]]
[[4je 9], [22jue 50], [74jue 50], [76jue 88]]

1. Contiguous merges such as [22 br 62] and [74 4J 62] < merge > 2. The part of intersection is removed, for example, [40 ~ (th) ~ (th) ~ (23)]

.

finally, we get
[[6jue 9], [22jue 74], [76jue 97]]
[[4je 9], [22jue 74], [76jue 88]]
and calculate the value of dividing the rest [[0jue 6], [9jue 22], [74jue 76], [97100]]

.
Mar.07,2021

function getRange(n = 3,min = 0,max = 100){
    if(max - min < 2*n-1){
        alert('');
        return false;
    }
    // n  2n 
    //[min+1 , max]
    let arr = {},i=0;
    while(i < 2*n){
        let random = Math.floor((max - min + 1)*Math.random());
        if(!arr[random]){
            arr[random] = random;
            iPP;
        }
    }
    //
    arr = Object.values(arr).sort((a,b)=>a-b);
    let ranges = [],ranges_ = [];
    arr.reduce((a,b,i,arr)=>{
        (i%2 == 0?ranges_:ranges).push([a,b])
        return b;
    },min)
    ranges_.push([arr[arr.length-1],max])
        
    return {ranges_,ranges}
}
//3[0,100],[1,100]
getRange();

this problem. It doesn't seem difficult, does it?

var obj = {};
var getRandom = (min = 1, max = 100) => {
    return Math.floor(Math.random()*(max-min+1)+min)
}
for(var i=0,il=getRandom(5,10);i<il;iPP){
    obj[getRandom()] = true; 
}
var _i = 0;
for(var i in obj){
    console.log(i)
}


your requirements are not clear, how many intervals do you have?
what output do you want in the end? What exactly is the
scope? The value is [1100]?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31b4c-2bdd0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31b4c-2bdd0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?