Home HTML JavaScript DOM Data Types

HACK COMPLETE

%%js

const person = {
  name: "Batman",
  age: 36,
  villans: ["Penguin", "Joker", "Two-Face", "Bane"],
  interests: ["Fighting Crime", "Justice", "Balling out",],
  heightInInches: 75,
  weightInPounds: 172,
};

console.log("Batman After:");
console.log(person);

person.villans.push("Adding Riddler and manipulating interests");
person.interests.shift();

console.log("Batman After:");
console.log(person);

const bmi = (person.weightInPounds / (person.heightInInches * person.heightInInches)) * 703;
const yearsUntilRetirement = 65 - person.age;
// Printing BMI
console.log("\nCalculations:");
console.log(`BMI: ${bmi.toFixed(2)}`);
console.log(`Years until retirement: ${yearsUntilRetirement}`);
// Printing types of variables
console.log("\nField Types:");
console.log(`Name is a ${typeof person.name}`);
console.log(`Age is a ${typeof person.age}`);
console.log(`Interests is an array: ${Array.isArray(person.interests)}`);
<IPython.core.display.Javascript object>