2nd Task

Explain the code line by line
 avatar
Clever
javascript
2 years ago
630 B
55
Indexable
Never
const person = {
  name: "Muhammad",
  age: 30,
  isAlive: true,
  salary: 20000,
  children: [
    {
      name: "Omar",
      age: 8,
      fatherless: false,
      starving: false,
    },
    {
      name: "Khaled",
      age: 10,
      fatherless: false,
      starving: false,
    },
  ],
};

person.children[0].name = "Mahmoud";

if (!person.isAlive) {
  person.children[0].fatherless = true;
  person.children[0].fatherless = true;
} else if (person.salary < 20000) {
  person.children[0].starving = true;
  person.children[0].starving = true;
} else {
  console.log("Everything Is Fine!");
}