Skip to content

Commit b7eec0d

Browse files
committed
objectToArray folder added with README and js file
1 parent d3ca52b commit b7eec0d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

L-B/0009 objectToArray/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# 0009 objectToArray ( L-B )
2+
3+
## Problem
4+
5+
Write a function to convert an object into an array of arrays containing key and value.
6+
7+
### Example
8+
9+
```
10+
objectToArray({ name: 'Will Smith', dob: '15-09-1968' }) => [['name', 'Will Smith'], ['dob', '15-09-1968']];
11+
```
12+
13+
## Solution
14+
15+
```javascript
16+
function objectToArray(object) {
17+
return Object.entries(object)
18+
}
19+
```
20+
21+
## References
22+
23+
- [Objects MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
24+
- [Arrays MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
25+
26+
## Problem Added By
27+
28+
- [GitHub](https://www.github.com/giomine)
29+
30+
## Contributing
31+
32+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
33+
34+
Please make sure to update tests as appropriate.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function objectToArray(object) {
2+
// console.log(Object.entries(object))
3+
return Object.entries(object)
4+
}
5+
6+
7+
objectToArray({ name: 'Giorgia 🌸', age: 'secret 😎', location: 'London 🇬🇧', occupation: 'programmer 👩🏻‍💻' })

0 commit comments

Comments
 (0)