I have an object that looks something like
names = {
m: [
'adam',
'luke',
'mark',
'john'
],
f: [
'lucy',
'mary',
'jill',
'racheal'
],
l: [
'smith',
'hancock',
'williams',
'browne'
]
};
What I want to do is.
I get a string that looks like
{m} {l} is a male name, so {f} {l} is a female name, {r} {l} must me a either/or(random) gender name
And I want it to randomly be populated from the correct keys.
so you might get
luke browne is a male name, so racheal smith is a female name, mary browne must be a either/or(random) gender name
How would I go about doing this?
the function skeleton would look something like
function names(mask, callback){}
and the last line of the code would be something like callback(replaced)
You can use
Math.random()to get a random value between 0 and 1. From there you can useMath.ceil()orMath.floor()with multiplication to get the desired range of values.