├── index.html
├── script.js
└── style.css
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Page Title
7 |
8 |
9 |
10 |
11 | حساب الوسط الحسابي
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/script.js:
--------------------------------------------------------------------------------
1 | function calculateMean() {
2 | const numbersInput = document.getElementById("numbers");
3 | const numbers = numbersInput.value.split(" ");
4 | const mean = calculateMeanFromArray(numbers);
5 | const resultDiv = document.getElementById("result");
6 | resultDiv.innerHTML = "الوسط الحسابي = " + mean;
7 | }
8 |
9 | function calculateMeanFromArray(numbers) {
10 | const sum = numbers.reduce((accumulator, currentValue) => accumulator + Number(currentValue), 0);
11 | const mean = sum / numbers.length;
12 | return mean;
13 | }
14 |
--------------------------------------------------------------------------------
/style.css:
--------------------------------------------------------------------------------
1 | label, input {
2 | display: block;
3 | margin-bottom: 10px;
4 | }
--------------------------------------------------------------------------------