+ 1

write a javascript code to print the table of a number enterd by the user using switch stetment please help

using switch stetment have to do it with switch statement it's a assignment

11th Sep 2018, 5:53 AM
Bishnu Chourasiya
Bishnu Chourasiya - avatar
2 Answers
+ 1
Follow Below Code function table(num) { switch (num) { case num: for(var i=1; i<=10; i++) console.log(num*i); break; } } table(8);
12th Sep 2018, 3:23 AM
Pramod Patil
Pramod Patil - avatar
+ 1
in this case, you don't neccessarily have to use a switch statement you could just use this var num=prompt(); for(i=1;i<11;i++;){ var num2 = num*i; document.getElementsByTagName("table").innerHTML+="<tr><td>"+num+" * "+i+"</td><td>"+num*i+"</td></tr> }
11th Sep 2018, 6:30 AM
Roel
Roel - avatar