0

I am trying to get the user to input a number, then input another number that will begin the multiplication table for the first number entered and continue on incrementing by one until the last number the user was prompted for is reached...

for example, if the user was to enter 10, then 1, then 10, the output would look like:

10 * 1 = 10
10 * 2 = 20
10 * 3 = 30
...
10 * 10 = 100


What am I doing wrong?

Thanks for the help!

function multiplierz(numberMultiplied, amountToMultiplyFirst, amountToMultiplyLast)
    {


        while (isNaN(numberMultiplied) = true || isNaN(amountToMultiplyFirst) = true || isNaN(amountToMultiplyLast) = true)
        {
            alert("YOU DID NOT ENTER ONLY NUMBERS. WAY TO GO DUMMY.");
            var numberMultiplied = prompt("Please Enter The Number to Multiply");
            var amountToMultiplyFirst = prompt("Start multiplying by which number?");
            var amountToMultiplyLast = prompt("End multiplying by which number?");
        }
        for (counter = amountToMultiplyFirst; counter <= amountToMultiplyLast; counter++)
            {
                document.write(numberMultiplied + " * " + counter + " = " + numberMultiplied * counter + "<br />");
            }
    }

    //Begin Program Below


        multiplierz(prompt("Please Enter The Number to Multiply"),prompt("Start multiplying by which number?"),prompt("End multiplying by which number?"));
</script>
0

3 Answers 3

4

Your isNan(numberMultiplied) = true is throwing an error. In javascript the = operator is for assignment.

Just do

while (isNaN(numberMultiplied) || isNaN(amountToMultiplyFirst) || isNaN(amountToMultiplyLast) )
Sign up to request clarification or add additional context in comments.

Comments

2

You need to use == instead of = in your while condition:

while (isNaN(numberMultiplied) == true || isNaN(amountToMultiplyFirst) == true || isNaN(amountToMultiplyLast) == true)
{
  ...
}

Comments

0

Simple thing that you didn't consider amountToMultiplyFirst should be less than amountToMultiplyLast :-)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.