Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- post = [
- {postTitle : 'Title1', key = 'key1'},
- {postTitle : 'Title2', key = 'key2'}
- ]
- comment = [
- {key : 'key1', c: "comment1"},
- {key : 'key1', c: "comment2"},
- {key : 'key2', c: "commentA"},
- {key : 'key2', c: "commentB"},
- {key : 'key2', c: "commentC"}
- ]
- newPost = [
- {
- postTitle : 'Title1', key = 'key1', comment: {"comment1", "comment2"}
- },
- {
- postTitle : 'Title2', key = 'key2', comment: {"commentA", "commentB", "commentC"}
- }
- ]
- for (var i = 0; i < post.length; ++i) {
- for (var j = 0; j < comment.length; j++) {
- if (post[i].key === comment[j].key) {
- post[i].comment = [];
- post[i].comment.push([comment[j].c]);
- }
- else {
- console.log('no comment to add'); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement