Skip to content
Snippets Groups Projects
Commit cbc52574 authored by Jon's avatar Jon
Browse files

Make sure that there are no orderID repetitions

parent 3c33bfec
No related branches found
No related tags found
No related merge requests found
......@@ -415,9 +415,19 @@ class Task3 {
for (let i = 1; i < 1000; i++){
ids.push(i);
}
let usedIndexes = [];
for (let i = 0; i < 6; i++){
let curOrderIndex = null;
while (curOrderIndex === null){
curOrderIndex = Math.floor(Math.random()*ids.length);
if (usedIndexes.includes(curOrderIndex)){
curOrderIndex = null;
} else {
usedIndexes.push(curOrderIndex);
}
}
let curOrder = {
'order-id': ids[Math.floor(Math.random()*ids.length)],
'order-id': ids[curOrderIndex],
'steak-level': levels[Math.floor(Math.random()*levels.length)],
'side': sides[Math.floor(Math.random()*sides.length)]
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment