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 해답 번역#225

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

Closed
1000peach wants to merge1 commit intojavascript-tutorial:masterfrom1000peach:solution_eval
Closed
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
6 changes: 3 additions & 3 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');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

프롬프트 창에 뜨는 메시지도 번역해주면 어떨까요?


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`을 검사하면 숫자와 연산자만 포함하게 됩니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

입력한 문자열을 산술적으로 제한하여라는 말이 잘 안와닿네요.
산술식만 입력하도록 제한한다는 의미인데, 조금 풀어써주세요.


[8]ページ先頭

©2009-2025 Movatter.jp