For or While


#1

var freeThrow = true;
var madeFreeThrowPoints = Math.ceil(Math.random * 2));

while(freeThrow) {
    if (madeFreeThrowPoints === 2) {
        console.log("You made the shot and you get 1 point.");        
    } else {
        console.log("You missed.");
    }
}

freeThrow();

I can't figure out where the hiccup is. I would appreciate any suggestions. Thank you!!!

Replace this line with your code.


#2

What is this line for?

You are trying to call a non-existent function.


#3

this line:

var madeFreeThrowPoints = Math.ceil(Math.random * 2));

random() is a function call, so it requires parentheses. also check all the parentheses on that line, there should be equal number of opening and closing parentheses, currently it is not balanced

then your loop:

while(freeThrow)

you never update freeThrow, this would be an infinity loop

then this line:

freeThrow();

it looks like a function call, but freeThrow() is not function, remove this line

which exercise is this? can you provide the url?


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.