Skip to content

Commit 9221303

Browse files
added problem number 18
1 parent d3ec110 commit 9221303

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
| Problem - 15 | Get the Middle Character |
2020
| Problem - 16 | Generate random boolean in JavaScript |
2121
| Problem - 17 | Find the largest number in Javascript |
22+
| Problem - 18 | Copy an Object deeply |
2223
<!-- | Problem - 18 | | -->

Diff for: problem-18.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// JavaScript allows you to deep copy an object by converting it into string and then back into object.
2+
3+
let obj = {
4+
name: 'mehedi',
5+
address: 'dinajpur',
6+
7+
};
8+
9+
const deepCopy = (obj) => {
10+
return JSON.parse(JSON.stringify(obj));
11+
};
12+
13+
console.log(deepCopy(obj));

0 commit comments

Comments
 (0)