Skip to content

Instantly share code, notes, and snippets.

@kopylovvlad
Created April 30, 2017 12:19
Show Gist options
  • Save kopylovvlad/13e1c36b5b905608deeed3e27315b482 to your computer and use it in GitHub Desktop.
Save kopylovvlad/13e1c36b5b905608deeed3e27315b482 to your computer and use it in GitHub Desktop.
groceryList = {}
groceryList['Bananas'] = 6
groceryList['Apples'] = 12
groceryList['Grapes'] = 2
groceryList['Kiwis'] = 10
groceryList['Pears'] = 8
console.log(groceryList['Kiwis'] == 10)
console.log(Object.keys(groceryList).length == 5)
for key, val of groceryList
console.log("#{key} = #{val}")
delete groceryList['Apples']
console.log(Object.keys(groceryList).length == 4)
values = []
for key, val of groceryList
values.push(val)
console.log(values)
console.log(Object.keys(groceryList))
for key of groceryList
delete groceryList[key]
console.log(Object.keys(groceryList).length == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment