chaesthetics / FrontEnd-Dev

For Meta Certification
0 stars 0 forks source link

for in, for of #35

Open chaesthetics opened 1 year ago

chaesthetics commented 1 year ago
// Task 1
var dairy = ['cheese', 'sour cream', 'milk', 'yogurt', 'ice cream', 'milkshake'];

function logDiary() {
       for(var dia of dairy){
           console.log(dia);
       }
}

// Task 2

const animal = {

canJump: true

};

const bird = Object.create(animal);

bird.canFly = true;
bird.hasFeathers = true;

function birdCan(){
    for(prop of Object.keys(bird)){
        console.log(`${prop}: ${bird[prop]}`); 
    }
}

function animalCan(){
    for(prop of Object.keys(bird)){
        console.log(`${prop}: ${bird[prop]}`); 
    }
    for(prop of Object.keys(animal)){
        console.log(`${prop}: ${bird[prop]}`);
    }
}

// Task 3

animalCan();