4
var Carro = function(){
var marca;
var modelo;
//this.setMarca = setMarca;
this.setMarca = function(_marca){
this.marca = _marca;
}
this.setModelo = function(_modelo){
this.modelo = _modelo;
}
this.getMarca = function() {
return this.marca;
}
this.getModelo = function(){
return this.modelo;
}
}
var carro = new Carro();
var marca = [];
var modelo = [];
var i;
var string = " ";
carro.setMarca("Volkswagen");
carro.setModelo("Camaro");
alert(carro.getMarca() + " " + carro.getModelo());
for(i=0;i<5;i++){
marca[i] = carro.getMarca() + " " + i;
modelo[i] = carro.getModelo() + " " + i;
string = string.concat(marca[i] + "\n");
string = string.concat(modelo[i] + "\n");
}
alert(string);
I have a car type class, in it have getters and setters for make and model.
Is it possible to store the data in a single vector? I separated it into two vectors so:
var marca = [];
var modelo = [];
Is there another way to merge both data into one vector? for example:
var car = [];
car|0|->marca = carro.getMarca();
car|0|->modelo = carro.getModelo();