I'm learning Javascript and created the below to take input from a user. If the number is between 150 and 300 it will print out the numbers from that number up till and including 300 in sequential order.
var num1;
conDition();
function conDition(){
num1 = prompt("Please enter a number: ");
if(num1 >= 150 && num1 <= 300){
outNum();
}else if(num1 < 150){
alert("The number is too low for this function.");
num1 = 0;
conDition();
}else if(num1 > 300){
alert("The number is too high for this function.");
num1 = 0;
conDition();
}else{
alert("That is not a number!");
num1 = 0;
conDition();
}
}
function outNum(){
do
{
document.write(num1 + "<br>");
num1++;
}while (num1 <= 300);
document.write("############################<br>");
return true;
}
Can you help me make this better (more efficient)?