posted an update

let sodium = {}; sodium.name = "sodium" sodium.abbr = "Na" sodium.mm = 22.99

let chlorine = {}; chlorine.name = "chlorine" chlorine.abbr = "Cl" chlorine.mm = 35.45

let compound = {}; compound.name = "salt" compound.abbr = "NaCl" compound.mm = 58.44 compound.mass = 10

compound.mole = compound.mass/compound.mm compound.array = [sodium, chlorine, oxygen]

for(var i = 0; i<compound.array.length; i++){ element=compound.array[i] element.mole = compound.mole element.mass = compound.mole*element.mm console.log(compound.array[i]) } This code gives all the information about the amount of sodium and chlorine that go into 10 grams of salt.

Log in or sign up for Devpost to join the conversation.