I only cut and paste the relevant code, my actual atom file has all the header code, the only reason I included the “body” section was because I’m trying to get user input for the exercise, otherwise I’d only have pasted the “script” section.
So here’s the entire code file:
<html lang="en">
<head>
<title>Sum of a Range</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>Sum of a Range</h1>
<input type="text" id="firstNum"> Enter 1st number</input><br><br>
<input type="text" id="secondNum"> Enter 2nd number</input><br><br>
<button id="makeArray">submit numbers</button><br><br>
<script>
let start = $("#firstNum").val();
let end = $("#secondNum").val();
function range(start, end, step = end > start ? 1: -1){
let numArray = [];
if (step > 0){
for (let i = start; i <= end; i += step)
numArray.push(i);
} else {
for (let i = start; i >= end; i += step)
numArray.push(i);
};
return numArray;
};
$("#makeArray").click(function(){
range(start,end)});
</script>
</body>
</html>