Skip to content

Commit 7807036

Browse files
committed
Combine Objects and adjustments to combine/union arrays
1 parent cc068ae commit 7807036

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

snippets/javascript/array-manipulation/combine-arrays.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Zip Arrays
3-
description: Combines two arrays by pairing corresponding elements from each array.
2+
title: Combine Arrays
3+
description: Concatenates two arrays into one.
44
author: JanluOfficial
5-
tags: array,map
5+
tags: array,concat
66
---
77

88
```js

snippets/javascript/array-manipulation/union-arrays.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Zip Arrays
3-
description: Combines two arrays by pairing corresponding elements from each array.
2+
title: Union Arrays
3+
description: Combines two arrays into one with unique elements.
44
author: JanluOfficial
5-
tags: array,map
5+
tags: array, set
66
---
77

88
```js
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Combine Objects
3+
description: Merges two objects into one.
4+
author: JanluOfficial
5+
tags: object,merge
6+
---
7+
8+
```js
9+
function combineObjects(obj1, obj2) {
10+
return { ...obj1, ...obj2 };
11+
}
12+
13+
// Usage:
14+
const obj1 = { a: 1, b: 2 };
15+
const obj2 = { c: 3, d: 4 };
16+
const combinedObject = combineObjects(obj1, obj2);
17+
console.log(combinedObject); // Output: { a: 1, b: 2, c: 3, d: 4 }
18+
```

0 commit comments

Comments
 (0)