One Hunnit
//get values from the page
function getValues(){
//get values from the page
let startValue = document.getElementById("startValue").value;
let endValue = document.getElementById("endValue").value;
//parse into Integers
startValue = parseInt(startValue);
endValue = parseInt(endValue);
if (Number.isInteger(startValue) && Number.isInteger(endValue)) {
//we call generateNumbers
let numbers = generateNumbers(startValue, endValue);
//we call displayNumbers
displayNumbers(numbers);
}else{
alert("You must enter integers");
}
}
//generate numbers from the startValue to the endValue
//logic function(s)
function generateNumbers(sValue, eValue){
let numbers = [];
//we want to get all numbers from start to end
for(let index = sValue; index <= eValue; index ++){
numbers.push(index)
}
return numbers;
}
//display numbers and mark the even numbers bold
//display or view functions
function displayNumbers(numbers){
let templateRows = "";
for (let index = 0; index < numbers.length; index++) {
let className = "even";
let number = numbers[index];
if(number % 2 == 0){
className = "even";
}
else{
className = "odd";
}
//This does not render correctly with prism
templateRows += `${number} `;
}
document.getElementById("results").innerHTML = templateRows;
}
The code is structed in one funtion.
Hello World
Hello World is a function that displays an alert with a message of "Hello World"