I want to display the multiplication table of input digit but this code is not working well by using switch statement. Please tell me where is mistake in this code.
const tables = (num) => {
switch (num.value) {
case num.value.match(/[0-9]+$/):
for (var i = 1; i <= 10; i++) {
document.write(`${num.value} * ${i} = ${num.value * i}<br>`)
}
break;
default:
return alert(`Invalid Entry!`)
break;
}
}
<body>
<p>Enter a number to get table: </p>
<input id="number" type="text">
<input type="submit" onclick="tables(number)">
</body>