For or While


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.");


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

Replace this line with your code.


What is this line for?

You are trying to call a non-existent function.


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:


you never update freeThrow, this would be an infinity loop

then this line:


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

which exercise is this? can you provide the url?


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