[Solved] Variable in Javascript

Anyone know how to set and use game Variables in the Javascripting?

I'm working on converting this:
Spoiler: Code
var RandomNames = {
firstNames: [
'Vinicius',
'Talita',
'Maria',
'João',
'José',
'Marcos'
],
middleNames: [
'Costa',
'Araújo',
'Rodrigues',
'Pereira',
'Soares'
],
lastNames: [
'Pires',
'Alves',
'Álvares',
'Moreira',
'Ferreira'
],
generate:function(quantity){
var maxNames = this.firstNames.length * this.middleNames.length * this.lastNames.length;
if (quantity > maxNames) {
throw "Quantity greater than possible matches. Possible matches: "+maxNames;
}
var names = [];
while ( names.length < quantity ) {
var name = "";
var first = Math.floor( Math.random() * this.firstNames.length );
name+= this.firstNames[first];
var middle = Math.floor( Math.random() * this.middleNames.length );
name+= " "+this.middleNames[middle];
var last = Math.floor( Math.random() * this.lastNames.length );
name+= " "+this.lastNames[last];

if (names.indexOf(name)==-1) {
names.push(name);
}
}
return names;
}
};

try {
var names = RandomNames.generate(150);
for (var i=0; i<names.length; i++) {
//Todo: Write the Variable Storage here.
// document.write(names+'<br/>');

}
//document.write('<br /><strong>Total names:</strong> '+names.length);
} catch (e) {
//document.write(e);
//Write the Error Handler here.
}

Hi there,

if you want to access game variables in script, you have to use GameManager.variableStore for example, for number variables:

The short-form
Code:
GameManager.variableStore.numbers[<index>] = <value>
var value = GameManager.variableStore.numbers[<index>]

The proper way
Code:
GameManager.variableStore.setNumberVariableAtIndex(<scope>, <index>, <value>, <optional-group>)
var value = GameManager.variableStore.numberVariableAtIndex(<scope>, <index>, <optional-group>)
Thank you, that helps a ton!

Original thread: https://forums.rpgmakerweb.com/threads/solved-variable-in-javascript.87366/