Skip to content

Instantly share code, notes, and snippets.

@timbec
Created April 30, 2018 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timbec/5e4bf29379ce93d363456eb395cea1f9 to your computer and use it in GitHub Desktop.
Save timbec/5e4bf29379ce93d363456eb395cea1f9 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/dodukacozo
var tags = [
{
id: 3,
name: "Stories",
created_at: "2018-04-06 14:24:25",
updated_at: "2018-04-06 14:24:25",
pivot: {
work_id: 14,
tag_id: 3
}
},
{
id: 5,
name: "Examples",
created_at: "2018-04-06 14:41:35",
updated_at: "2018-04-06 14:41:35",
pivot: {
work_id: 14,
tag_id: 5
}
}
]
var tagArray = [];
var i, item;
for (i = 0; i < tags.length; i++) {
for (item in tags[i]) {
if (item === 'name') {
console.log(tags[i][item]);
tagArray.push(tags[i][item]);
}
}
}
console.log(tagArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment