# ⑤4: Average

By [AlchemyUniversity非公式和訳置き場](https://paragraph.com/@alchemyuniversity) · 2023-01-13

---

### Division Operator

### 除算演算子

.

.

This stage we're going to introduce a new operator, the division operator: `/`.

今回は新しい演算子、除算演算子：/を紹介します。

.

The divide operator takes two inputs and divides the left-side by the right-side. So `8 / 4` would evaluate to `2`.

除算演算子は2つの入力を受け取り、左側の値を右側の値で割ります。なので8/4は2になります。

.

.

### Averaging Numbers

### 平均値を求める

.

.

In this exercise we're going to work on averages.

この練習では平均値について学びます。

.

Let's **think** about how to determine the average of three numbers.

3つの数字の平均値をどう求めるか考えてみましょう。

.

The average of the three values `4`, `5` and `6` is `5`. The algorithm for figuring this out is summing all three values and then dividing by the total number of values (`3`).

4、5、6の3つの値の平均値は5です。それを求めるアルゴリズムは3つの値を足し合わせ、その後全体の値で割ることです（3）。

.

In this case, the sum of `4`, `5`, and `6` is `15`. Then we divide `15` by `3` (`15 / 3`) to get `5`.

この場合、4、5、6の合計は15です。その後、15を3で割ります（15/3）して5を得ます。

.

In order to ensure that the operations occur in the order you expect you can break them up line by line:

演算が期待通りに行われるようにするためには、1行1行に分けることができます。

.

    const sum = 1 + 2 + 3;
    const average = sum / 3;
    

.

**Or** you can use parenthesis:

または、括弧を使用することもできます。

.

    const average = (1 + 2 + 3) / 3;
    

.

Learn more about the order of operations in [details](https://university.alchemy.com/course/js/sc/5d7d8df209d5ed335cbf0912/stage/5d7e6c6f09d5ed335cbf091f?tab=details).

演算順序について更に学ぶには、Detailsを参照してください。

.

.

### Your Goal: Complete the average function

### 目標：average関数を完成させる

.

.

1.Taking what you learned above, find the average of **four** numerical values `a`, `b`, `c`, and `d`.

1.上記で学んだことを使用して、4つの数値a、b、c、dの平均値を求めます。

.

2.Once you have found the average, be sure to `return` it.

2.平均値を求めたら、必ずそれをリターンで返しましょう。

.

.

. . Operator Precedence 演算子の優先順位 . . We've learned about a few operators so far: `+`, `-`, `*` and `/`.. これまでに+、-、\*、/などの演算子について学びました。 . Multiplication and division have a **higher precedence** than addition and subtraction. 乗算と除算は加算と減算よりも優先順位が高くなります。 . 5 + 1 \* 2 . This statement would evaluate to `7`. The multiplication operator takes precedence over the addition operator. この文は7に評価されます。乗算演算子は加算演算子よりも優先されます。 . If the operators are of the **same precedence**, like multiplication and divide, the expression will be evaluated from **left-to-right**: 同じ優先順位の演算子がある場合、左から右に評価されます： . 4 / 4 \* 2 . This statement would evaluate to `2` because the division is the first operation from left-to-right. この文は左から右に評価される最初の演算である除算が原因で2に評価されます。 . If you're not sure about the operator precedence, you can always use parenthesis: 演算子の優先順位がわからない場合は、常に括弧を使用できます： . (5 + 1) \* 2 . This will evaluate to `12`. **The parenthesis will always be evaluated first** before any other part of the expression. これは12に評価されます。括弧は式のどの部分よりも先に評価されます。 . NEXT⇒⇒ [https://mirror.xyz/0x1E768F62Ab8678af5c977Ee880eC8012e1ce3c4F/UIFULhsl1-o6oPPTNJ3q2Hv8EfTDd2nA9wbkNLCR4t4](https://mirror.xyz/0x1E768F62Ab8678af5c977Ee880eC8012e1ce3c4F/UIFULhsl1-o6oPPTNJ3q2Hv8EfTDd2nA9wbkNLCR4t4)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

---

*Originally published on [AlchemyUniversity非公式和訳置き場](https://paragraph.com/@alchemyuniversity/4-average)*
