I need help answering these JavaScript Questions.?

How many times will this for-loop run? Assume x is a number/integer. for( x = ; x < ; x++ ) { }

times

times

times

times

times

How many times will this for-loop run? Assume x is a number/integer. for( x = ; x <= ; x++ ) { }

times

times

times

times

times

How many times will this for-loop run? Assume x is a number/integer. for( x = ; x < ; x += ) { }

times

times

times

times

times

How many times will this for-loop run? Assume x is a number/integer. for( x = ; x >= ; x -= ) { }

times

times

times

times

times

✅ Answers

  • For each question, just memorise the number, x.

    Then, count up (or down) from that number in the required intervals, until the condition is “false”.

    So for the first one, you would go:

    Ok, let’s remember .

    How much is it going up by? Oh, , that’s easy enough!

    Right, let’s get a tally going.

    , , , , , , , , , , …

    Oh, right! <, but isn’t <; it’s equal. Righty-oh then, that went from to . That’s numbers, so the answer’s (B).

    Hope this helps, I wasn’t going to just give you the answers.

    Just remember to always check how high it’s going, whether it can be equal to the number cap, and how much it’s going up by!

    Hnefatl

  • Easiest way is to actually run the code.

    . times

    . times

    . times

    . times

    You could also follow through the code yourself and count how many times.

  • When you set “i < aNumber” it stops the number before that number so “i < ” would loop times. and on the last one you have a – there by the = sign. you also set a value for x twice there. So a lot of your code is messed up. And if you say that i messed something up that is basic html and i scored better than most people at JavaScript. I have over a . score for JavaScript.

    Source(s): IU code HTML, JavaScript, And more

  • Leave a Comment