The Coder For: Speedo
//get the values from UI
function getValues(){
//get values from the page
let startValue = document.getElementById("startValue").value;
let endValue = document.getElementById("endValue").value;
startValue = parseInt(startValue);
endValue = parseInt(endValue);
if(Number.isInteger(startValue)&& Number.isInteger(startValue)){
//calls createNumbers
let numbers= createNumbers(startValue,endValue);
//Calls the displayNumber Functions
displayNumbers(numbers);
}
else{
alert("You must enter integer!")
}
}
//generate numbers from start value to the end value
function createNumbers(sValue, eValue){
let numbers = [];
for(let i=sValue; i<=eValue;i++ ){
numbers.push(i);
}
return numbers;
}
//display the numbers and bold the even numbers
function displayNumbers(numbers){
let templateRows = [];
for(let i=0; i${number} `;
}
else{
templateRows += `${number} `;
}
}
document.getElementById("results").innerHTML = templateRows;
}
The Code is structure in three function.
getValues
The getValues function will get the value from the user input values from the page.
createNumbers
The createNumbers function will take the start and end values and will put it in array and will return the array.
displayValues
The displayValues function will display the values in the tbody tag of the table where even numbers will be printed in bold.