File tree Expand file tree Collapse file tree
9-regular-expressions/09-regexp-groups/5-parse-expression Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # Parse an expression
1+ # Разобрать выражение
22
3- An arithmetical expression consists of 2 numbers and an operator between them, for instance :
3+ Арифметическое выражение включает два числа и оператор между ними. Например :
44
55- ` 1 + 2 `
66- ` 1.2 * 3.4 `
77- ` -3 / -6 `
88- ` -2 - 2 `
99
10- The operator is one of : ` "+" ` , ` "-" ` , ` "*" ` or ` "/" ` .
10+ Оператором может быть : ` "+" ` , ` "-" ` , ` "*" ` или ` "/" ` .
1111
12- There may be extra spaces at the beginning, at the end or between the parts .
12+ В выражении могут быть пробелы вначале, конце или между частями выражения .
1313
14- Create a function ` parse(expr) ` that takes an expression and returns an array of 3 items :
14+ Создайте функцию ` parse(expr) ` , которая принимает выражение и возвращает массив из трех элементов :
1515
16- 1 . The first number .
17- 2 . The operator .
18- 3 . The second number .
16+ 1 . Первое число .
17+ 2 . Оператор .
18+ 3 . Второе число .
1919
20- For example :
20+ Например :
2121
2222``` js
2323let [a, op, b] = parse (" 1.2 * 3.4" );
You can’t perform that action at this time.
0 commit comments