Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

eval 해답 번역 및 수정사항 반영#276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Violet-Bora-Lee merged 1 commit intojavascript-tutorial:masterfrom1000peach:solution_eval
Oct 18, 2019
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions1-js/99-js-misc/02-eval/1-eval-calculator/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
Let's use`eval` to calculate the maths expression:
산술 표현식을 계산하기 위해`eval`을 사용해봅시다.

```js demo run
let expr = prompt("Type an arithmetic expression?", '2*3+2');
let expr = prompt("산술 표현식을 입력하시겠습니까?", '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.
문자열을 산술 표현식만 입력하도록 제한하여 안전하게 eval로 실행하기 위해, [정규 표현식](info:regular-expressions)을 사용하여 `expr`을 검사하면 숫자와 연산자만 포함하게 됩니다.

[8]ページ先頭

©2009-2025 Movatter.jp