FrontEnd.ro logo
Funcții pe Array-uri / partea 2
let friends = [
  { name: "Alex", hasDrivingLicense: false },
  { name: "Jon", hasDrivingLicense: false },
  { name: "Diana", hasDrivingLicense: true }
];

let driver = friends.find((friend) => {
  return friend.hasDrivingLicense === true;
})

if (driver !== undefined) {
  console.log(`${driver.name} will drive`);
} else {
  console.log("I guess we'll take the train...");
};