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.

28 lines
891 B

## Find Expression
### Instructions
5 years ago
Create a function called `findExpression` that takes a number as parameter and returns a string
- It will be given two constant variable `add4` and `mul2`
- Your goal is to try to find a sequence, starting from the number 1, and repeatedly either adding 4 or multiplying 2
that produces the number given has parameter.
For example, the number 8 you must first multiplying by 2 twice and then add 4.
It will look something like this `1 *2 *2 +4`
- If the number can not be reached you should return `undefined`
### Notions
- [https://nan-academy.github.io/js-training/examples/loops.js](https://nan-academy.github.io/js-training/examples/loops.js)
- [https://nan-academy.github.io/js-training/examples/recursion.js](https://nan-academy.github.io/js-training/examples/recursion.js)
5 years ago
### Code provided
```js
const add4 = '+4'
const mul2 = '*2'
```