FratmScript 馃馃徎

Lesson 8 / 14

Objects

An object groups several named values: { nome: "Margherita", prezzo: 6 }. You read them with pizza.nome.

Destructuring takes several fields in one go: chist 猫 { nome, prezzo } = pizza.

Exercise

Take nome and prezzo with destructuring and print "Margherita: 6 euro".

chist 猫 pizza = {
    nome: "Margherita",
    prezzo: 6,
    ingredienti: ["pummarola", "muzzarella", "basilico"],
}

stamm a d矛(pizza.nome)

chist 猫 { ingredienti } = pizza
stamm a d矛(ingredienti.join(", "))

When you are done, the program prints

Margherita: 6 euro

Do this lesson in the playground