Here is the problem. I have an object with property and value and I iterate through the object in order to get property and want to map this property with an array of qualityCharacter and after output I get this: ;;;;;
instead of it: human ; Maksym ; male ; 2 ; 2 ; Hello world!
`
const inhabitants = {
dog: {
species: "dog",
name: "Barsik",
gender: "male",
legs: 4,
hands: 0,
saying: "woof-woof!"
},
cat: {
species: 'cat',
name: 'Markiz',
gender: 'male',
legs: 4,
hands: 0,
saying: 'meow'
},
man: {
species: 'human',
name: 'Maksym',
gender: 'male',
legs: 2,
hands: 2,
saying: 'Hello world!'
},
woman: {
species: 'human',
name: 'Khristina',
gender: 'female',
legs: 2,
hands: 2,
saying: 'Hi world!'
},
catWoman: {
species: "cat",
name: "Murka",
gender: "female",
legs: 2,
hands: 2,
saying: ""
}
};
inhabitants.catWoman.saying = inhabitants.cat.saying
// I try to iterate through object with for in loop.
const inhabitant = (species) => {
for (let property in species) {
const allSpecies = [];
allSpecies.push(property);
const qualityCharacter = ['species', 'name', 'gender', 'legs', 'hands', 'saying'];
allSpecies.map(character => console.log(qualityCharacter.map(quality => character[quality]).join(";")));
}
}
inhabitant(inhabitants);