move misc to js/ui

This commit is contained in:
Ilya Kantor 2019-06-22 10:17:44 +03:00
parent 594ac2b012
commit 4a48deeb2c
18 changed files with 4 additions and 4 deletions

View 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.