+ 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
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);
+ 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>
}