JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<title>Number Calculator</title>
</head>
<body>
<input type="text" id="number">
<button id="hitung">HITUNG</button>
<p id="hasil"></p>
</body>
</html>
JavaScript
let numberInput = document.getElementById("number");
let btn = document.getElementById("hitung");
let hasil = document.getElementById("hasil");
btn.addEventListener('click', function () {
let number = parseInt(numberInput.value); // Parse the input value as an integer
//angka 10 artinya perulangan 10 kali
for (let index = 0; index < 10; index++) {
number += 500;
}
hasil.innerHTML = "Hasil: " + number;
});