Commit 030d176e by amir

randomize strings

parent 68b82007
Showing with 8 additions and 1 deletions
......@@ -52,6 +52,10 @@ function randomIntBetween(minValue,maxValue){
return parseInt(Math.min(minValue + (Math.random() * (maxValue - minValue)),maxValue));
}
function randomStringBetween(values){
return values[parseInt(Math.random() * values.length)]
}
function handleChild(child, parent) {
var obj = parent[child];
switch (typeof obj){
......@@ -60,7 +64,7 @@ function handleChild(child, parent) {
break;
case 'string':
var args = obj.split(":");
if (args.length == 4){
if (args.length >= 4){
if (args[0] == 'R'){
var startRange = args[2];
var endRange = args[3];
......@@ -72,6 +76,9 @@ function handleChild(child, parent) {
case 'F':
parent[child] = randomFloatBetween(startRange,endRange);
break;
case 'S':
parent[child] = randomStringBetween(args.slice(2,args.length));
break;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment