JSFiddle - React, Tailwind, and code Playground
HTML
<label for="value">Enter Value: </label>
<input id="value1" class="value1" type="number" title="value field" placeholder="e.g. 1000">
<button type="button" id="solution1_btn" title="solution 1 button">Enter</button>
<input id="result1" class="result1" type="number" disabled>
JavaScript
// click button
var solution1 = document.getElementById("solution1_btn");
// user entered value
//var value1 = document.getElementById("value1");
//console.log(value1);
// result input field
var result1 = document.getElementById("result1");
var value1 = document.getElementById("value1");
function multiples(event) {
var fix = parseInt(value1.value);
// declare sum assign it value 0
var sum = 0;
// declare a for loop that iterates while the counter "i" is less than fix
for (var i = 0; i < fix; i++) {
// if statement test whether the division remainder of 3 and 5 are equal to 0
if (i % 3 == 0 && i % 5 === 0) {
// assigns the value of i to sum
sum += i;
var newSum;
newSum = sum;
};
};
// returns the value of sum from the function callback argument 1000 etc.
result1.value = newSum
};
solution1.onclick = multiples;