Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.12 KB

dynamic_properties.md

File metadata and controls

41 lines (30 loc) · 1.12 KB

Dynamic Properties

Short demonstration on how to add dynamic properties to a JavaScript object.

var data = {
    'PropertyA': 1,
    'PropertyB': 2,
    'PropertyC': 3
};

data["PropertyD"] = 4;

// dialog box with 4 in it
alert(data.PropertyD);
alert(data["PropertyD"]);

I used this for an Exercism.io problem: "ETL" :

export const transform = (oldData) => {
    let newData = new Object()

    for (let [key, value] of Object.entries(oldData)) {
        value.forEach(element => {
            newData[element.toLowerCase()] = parseInt(key);
        });
    }

    return newData;
};

REF: Exercism.io "ETL", solution

Resources and References