move misc to js/ui
This commit is contained in:
parent
594ac2b012
commit
4a48deeb2c
18 changed files with 4 additions and 4 deletions
11
1-js/99-js-misc/02-eval/1-eval-calculator/solution.md
Normal file
11
1-js/99-js-misc/02-eval/1-eval-calculator/solution.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
Let's use `eval` to calculate the maths expression:
|
||||
|
||||
```js demo run
|
||||
let expr = prompt("Type an arithmetic expression?", '2*3+2');
|
||||
|
||||
alert( eval(expr) );
|
||||
```
|
||||
|
||||
The user can input any text or code though.
|
||||
|
||||
To make things safe, and limit it to arithmetics only, we can check the `expr` using a [regular expression](info:regular-expressions), so that it only may contain digits and operators.
|
11
1-js/99-js-misc/02-eval/1-eval-calculator/task.md
Normal file
11
1-js/99-js-misc/02-eval/1-eval-calculator/task.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
importance: 4
|
||||
|
||||
---
|
||||
|
||||
# Eval-calculator
|
||||
|
||||
Create a calculator that prompts for an arithmetic expression and returns its result.
|
||||
|
||||
There's no need to check the expression for correctness in this task.
|
||||
|
||||
[demo]
|
Loading…
Add table
Add a link
Reference in a new issue