You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
799 B

## Fusion
4 years ago
### Instructions
The objective of this exercise is to merge objects into a new object depending on the values type
With this create a function called `fusion` that:
4 years ago
- If the type is an array you must concat it
```js
fusion([1,2], [3,4]) // -> [1,2,3,4]
```
4 years ago
- If it is a string you must concatenate with a space
```js
fusion('Salem', 'alem') // -> 'Salem alem'
```
4 years ago
- If it is numbers you must added them
```js
fusion(4, 11) // -> 15
```
- In case of type mismatch you must replace it with the value of the second object
```js
fusion({ a: 'hello', b: [] }, { a: 4 })
// -> { a: 4, b: [] }
```
4 years ago
- If it is an object you must fusion them recursively
```js
fusion({ a: 1, b: { c: 'Salem' } }, { a: 10, x: [], b: { c: 'alem' } })
// -> { a: 11, x: [], b: { c: 'Salem alem' } }
```