If you’re writing this behind HTML, then the browser window will be where to display the result, not the console, as the use cannot see that. What’s more, since it is in a browser window then a form control would be the way to get user input, not a `prompt`

dialog.

```
<body>
<div>
<input type="number" id="number">
<button id="enter">Enter</button>
<input id="result" type="text" value="" readonly>
</div>
</body>
```

Then in the JS,

```
const number = document.querySelector('#number');
const enter = document.querySelector('#enter');
const result = document.querySelector('#result');
const series = () => {
var n = number.value;
var total = 0;
for (let i = 1; i <= n; i++) {
total += i;
}
result.value = total;
};
enter.addEventListener('click', series);
```

And that is that. No `onclick`

attribute, no `prompt().`

, no `console.log()`

.

##
complete code

```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Series</title>
</head>
<body>
<div>
<input type="number" id="number">
<button id="enter">Enter</button>
<input id="result" type="text" value="" readonly>
</div>
<script>
const number = document.querySelector('#number');
const enter = document.querySelector('#enter');
const result = document.querySelector('#result');
const series = () => {
var n = number.value;
var total = 0;
for (let i = 1; i <= n; i++) {
total += i;
}
result.value = total;
};
enter.addEventListener('click', series);
</script>
</body>
</html>
```

Mathematically there is a simpler way to add a sequence:

```
let n be the number of terms in the sequence
let a be the first term
let z be the last term
let s be the sum of the sequence (series)
so that,
s = (a + z) * n / 2
```

Try it.

```
a = 1
z = 100
n = 100
(1 + 100) * 100 / 2 =>
101 * 50 =>
5050
```