Trying to create a multiplication table, the for loop won't work for some numbers

Trying to create a multiplication table, the for loop won't work for some numbers
0

#1

Hi, so I’m trying to code a program which takes two numbers as input, and prints a multiplication table between those two numbers (ex- if we entered 2 and 6, it will print tables for 2, 3, 4, 5 and 6). So far the code works, but not for all inputs, on entering 2 and 10, I get no output, same with any number from 2-9 as the first input, and 10 as the second one, the code won’t work, any help would be really appreciated!

Codepen Link: https://codepen.io/goprime/pen/LgMpJo


#2

You’re getting the value as a string, transform it into a number, for example:

element = Number(document.getElementById('element').value);

You can also use parseInt or parseFloat depending on your requirements.


#3

Thank you so much! It works perfectly now