JSFiddle - React, Tailwind, and code Playground
by Riivr
HTML
<input id="answer" />
JavaScript
var number = 3
function multiplesOf3and5(number) {
var numberArray = [];
var total = 0;
for(var i=1; i <= number; i++){
if(i % 5 == 0) {
numberArray.push(i);
} else if (i % 3 == 0) {
numberArray.push(i);
}
}
for(var num in numberArray) {
total += num;
}
return total;
}
var test = multiplesOf3and5(number);
$("#answer").val(test);