I’m trying to create a function that returns the 12 times table of a given number that a user submits through a form. The user inputs a number through an input box and clicks the times button.
Then a 12 times table for that number is listed. I’m having trouble outputting the array from the function to the front end page.
function timestable(x) {
let x = Number(document.userNum.Number.value);
let table = [];
for (i = 0; i++; i < 13) {
value = x * i;
table.push(value);
}
return table;
};
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form name="userNum">
Number: <input type="text" name="number1">
<button onclick="timestable()">Times</button>
</form>
</body>
</html>