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

2nd Dec 2020, 10:06 AM
Asrar Ali
Asrar Ali - avatar
5 Réponses
+ 3
Could u show ur code
2nd Dec 2020, 10:09 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 2
You shouldn't use do-while loop Simply use if-else choice = prompt( ... )... if(yes){ // prints table }
2nd Dec 2020, 12:28 PM
Gordon
Gordon - avatar
0
Yes w8
2nd Dec 2020, 10:30 AM
Asrar Ali
Asrar Ali - avatar
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); }
2nd Dec 2020, 10:36 AM
Asrar Ali
Asrar Ali - avatar
0
Thanks buddy gordon
3rd Dec 2020, 6:14 AM
Asrar Ali
Asrar Ali - avatar