What happens is that I'm creating an object calling clanes
, within which are all the clans, in an array clan
, and another with its supposed owners , but as I can know , that, in the case of my example, the clan 'DW'
, belongs to 'Javier'
?
var clanes = {
name: [],
owner: []
};
function crear(clan, owner) {
var c = clan.toString();
var d = owner;
clanes.name.push(clan);
clanes.owner.push(d);
}
crear("DW", "Javier")
crear("ZT", "Pedro")
console.info(clanes);
It occurred to me something like going through all the properties of the object, and since they are all arrays, if they have the same index, they have found the owner, but I did not clarify ..
I tried this:
var dueño = "";
for(var i in clanes) {
if(clanes.name[i] == clanes.owner[i]) {
dueño = clanes.owner[i];
console.info("El dueño de :" + clanes.name[i] + " es: " + dueño);
}
}