Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Why does this code not work? Any insight would be great!

    var timeTables = function(number) {

        for(var i = 1; i <= 12; i++) {
            var userAns = prompt("What is " + number + " x " + i),
                result = number * i;
            if(userAns === result) {
                alert(userAns);
            }
        }
    };

            timeTables(2);

2 Answers

What error are you getting, if any at all? What isn't working?

For future reference, more details would be a good thing ;) But it's an understandable mistake for anyone new. Welcome to Treehouse!

=== doesn't perform type conversion.

You seem to be referring to certain variables as strings then numbers, try == and see if that works?