случайные id

This commit is contained in:
Dmitry Borisenko
2022-09-18 19:26:23 +02:00
parent 3c7606b14d
commit f4443d2d66
4 changed files with 19 additions and 12 deletions

View File

@@ -25,6 +25,7 @@
if (itemsJsonBind === item.num) {
delete item.num;
delete item.name;
item.id = item.id + randomInteger(0, 100);
configJson.push(item);
configJson = configJson;
itemsJsonBind = 0;
@@ -34,6 +35,12 @@
}
}
function randomInteger(min, max) {
// получить случайное число от (min-0.5) до (max+0.5)
let rand = min - 0.5 + Math.random() * (max - min + 1);
return Math.round(rand);
}
function deleteLineFromConfig(num) {
for (let i = 0; i < configJson.length; i++) {
if (num === i) {