0
I make tables program using " do loop " in javascript
that asks first" do u want to print the tables" if i say yes it prints table but when i say no it prints tables too. đ Any body tell me how i fix it
5 Answers
+ 3
Could u show ur code
+ 2
You shouldn't use do-while loop
Simply use if-else
choice = prompt( ... )...
if(yes){
// prints table
}
0
Yes w8
0
Here is the code bro:
var choice =" ";
do
{
choice = prompt("Do u want to print the table y/n");
}
while(choice =='y' || choice =='Y')
var table1 = parseInt(prompt("Enter table number 1"));
var table2 = parseInt(prompt("Enter table number 2"));
var table3 = parseInt(prompt("Enter table number 3"));
var start = parseInt(prompt("Enter startnumber "));
var end = parseInt(prompt("Enter end number "));
for(i = start ; i<=end ;i++){
document.write(+table1+"*"+i+"="+table1*i +" " +table2+"*"+i+"="+table2*i +" " +table3+"*"+i+"="+table3*i);
}
0
Thanks buddy gordon