Loops - Reading Assignment

  1. Repeat some code segment based on some condition being true so that we can just write the loop and not repeat ourselves.
  2. Loops run some code segment repeatedly based on some condition evaluating to true.
  3. While checks condition first do-while check condition after running code once.
  4. Indentation is whitespaces added to the beginning of lines to make the code more readable and to better reflect the structure of the code.

1.Looping control flow allows us to go back to some point in the program where
we were before and repeat it with our current program state.

2.Loops will keep going to all predefined states in a program unless a condition is set to stop.

  1. The only difference is that a Do loop executes it’s body at least once and then checks if it should go on or not.

  2. Adding spaces to chunks of code in order to make it stand out

  1. What is looping control flow allowing us to do?
    Looping control flow allows us to go back to some point in the program where we were before and repeat it with our current program state.
  2. Describe what “loops” do in your own words.
    A loop make it possible to repeat code as long as a condition is true. Thus, we could by adding some logic we could make a code repeat a given number of times or as long as a special condition still hold true. This safes time and gives the opportunity of clever design and smart solutions. Also it gives the code simple and easy to read instead of having an enormous amount of repeating code.
  3. What is the difference between while and do-loops?
    A while loop would used be invoked if the condition is true, potentially never. As for do-loops would at least execute the code once, thereafter would repeating execution of the code depend on the condition being true or false.
  4. What is indentation?
    Indentation is to step in when including a block inside a statement like If-else or while-do loops, thereby getting more readable code which is easier for you to control and easier for others to read. You could have all your code in one line, the compiler does not care, but for us there is easier to manage code when structured by using lines of code and indentation to show which code that are executed in the same block.
  1. What is looping control flow allowing us to do?
    Looping control flow allows us to go back to a previous point in a program and repeat it with our current program state.

  2. Describe what “loops” do in your own words.
    Loops create conditions for a program to repeat a step until the specified condition is satisfied.

  3. What is the difference between while and do-loops?
    A while-loop creates a statement that will continue to be entered by the program as as the expression gives a value equal to true when converted to boolean. A do-loop is similar except it always executes its body at least once and it starts testing whether it should stop only after that first execution.

  4. What is indentation?
    Indentation is a way of organizing lines of code by indenting each level of a program further and further to show what is inside of what and where the each block begins/ends vs where the block inside of it begin/end.

  1. What does looping control flow allow us to do?
    Looping control flow allows us to go back to some point in the program where we were before and repeat it with our current program state.

  2. Describe what “loops” do in your own words.
    Loops allow us to complete repetitive, sequential tasks very quickly (once we have set it up correctly).

  3. What is the difference between while and do loops?
    While and do loops are very similar. The difference is that a do loop always executes its body at least once, and it starts testing whether it should stop only after that first execution.

  4. What is indentation?
    Proper indentation provides visual shape to a program that corresponds to the shape of the informational blocks inside it.
    It helps to visually organize the program.

What is looping control flow allowing us to do?
It evaluates variables and/or constants to execute a section of code.

Describe what “loops” do in your own words.
Its a control flow that evaluates a boolean expression in order to continue with an increasing or decreasing variable used in the code or not.

What is the difference between while and do-loops?
DO loops execute at least once with the boolean expression at the end of the code.

What is indentation?
Just spaces that don’t execute anything rather to visual ordering of the code.

1- Looping contro lflow allows us to go back to some point in the program where we were before and repeat it with our current program state.
2- Loops allow us to execute a piece of code repeatedly until a condition is met.
3- A while loop while execute only if a boolean condition is true, the do loop is executed at least once, and then the condition is checked to see if it should continue to be executed
4- Indendation is used to give clarity to the code. It’s not necessary, but it’s useful to make the program human-readable.

  1. Looping control flow allows us to run a section of code multiple times

  2. In programming there are sections of code that require repetition. In order to minimise the work and make the code readable and maintainable, we need a way be able to repeat sections of code multiple times. Loops are sections of programs that allow us to express long computations without writing masses of code.

  3. While-loops execute the conditional expression for the loop at the start, so if the condition for the loop is evaluated to be false at the start, the while loop will never be executed. Do-loops execute at least once, even if the condition for the loop is false. The evaluation for the condition of the loop is done after the first execution

  4. Indentation is the act of adding white spaces such as space, tabs and new lines to code, to make the structure of te code stand out. Indentation makes code easier to read, which helps understand, fix issues and maintain in the long term.
  1. What is looping control flow allowing us to do? - looping allows multiple iterations of code without coding each specific step
  2. Describe what “loops” do in your own words. - looping allows multiple iterations of code to run given a set of conditions
  3. What is the difference between while and do-loops? “do” loops always execute its body at least once. “while” loops keep entering the statement until it produces a value that gives true when converted to Boolean.
  4. What is indentation? Formatting the code in a way that is easier to read and decipher.
  1. looping control flow allows us to run a piece of code multiple times. it allow us to go back to the same point in the program where we were before and repeat it with our current program state.
  2. A loop is a way of repeating lines of code more than once
  3. A do loop always executes its body at least once, and it starts testing whether it should stop only after that first execution.
  4. The role of indentation inside a block is to make the structure of the code stand out. With proper indentation, the visual shape of a program corresponds to the shape of the blocks inside it.
  • What is looping control flow allowing us to do?
    it allows us to go back to some points in the program and repeat it with the current program state

  • Describe what “loops” do in your own words.
    loops repeat a certain part of program over and over again

  • What is the difference between while and do-loops?
    do-loop executes its body at least once

  • What is indentation?
    adding spaces to the code to make is clearer

Ans.1 Run repeat code as long as Answer is true
Ans.2 Loops run a piece of code over and over until the desired results are met.
Ans.3 The phase while may execute the program 0-1 times. the boolean statement must be true at
the block indicator for statement to be true.
Ans.4 An indentation is used to display the structure of the code as blocks make it easier to read.

  1. It is allowing us to run a code multiple times with control (the programmer decides how many times and for what reason).

  2. Lets say that I want to count from 1 to 10. Then I write the code like this.
    var number = 1;

    while (number < 11) {
    console.log(number);
    number++
    }

    What happens here is that it starts from the first value that we have declared for number. The program writes 1(or console.log(1); is written) and then it increments number to 2 and then when the code is running again it writes 2. It keep on writing and incrementing until number is reaching 11 and then it stops.
    It does not write 11 because it stops the loop when 11 is reached. If you write “while (number <= 11)” then it writes the 11 aswell.

  3. The difference is that do loops is running at least once compared to while loops which only runs if the conditions are being met.

  4. It is the spaces you are putting out in the code for making it easier to follow/read.
    Example:
    if (a > b) (SPACE HERE) {
    alert (“hello”);
    if (c > d) (SPACE HERE) {
    alert(“hello again”);
    } (<— notice that this bracket is in line with the “if (c > d)”-statement)
    }

  1. Allows us to go back to some point in the program and repeat it with our current program state.
  2. Loops make the program run the code until certain criteria are met.
  3. The while loops will run as long as the expression produces a value that gives true, when converted to Boolean.
    A do loop always executes its body at least once.
  4. Spaces in front of statements - are not required, but make the structure of the code to stand out.
  1. Looping control flow allows the program to return to a specific point in the code and repeat it a number of times until the conditions for exiting the loop are met.

  2. Loops repeat portions of code.

  3. The only difference between “while” and “do” loops is “do” loops always execute at least once, then check to see whether it should be executed again. “while” loops may never be executed if the conditions are not met.

  4. Indentation is used to keep code clear and organized. It does not affect the execution of the code.

  1. What is looping control flow allowing us to do?
    Looping control flow allows one to continue executing an expression until the condition within the loop is false.

  2. Describe what “loops” do in your own words.
    A loop is an expression that repeats itself until the condition is no longer valid.

  3. What is the difference between while and do-loops?
    A do loop executes at least once, while a while loop may not necessarily execute.

  4. What is indentation?
    A space denoting where one block of code ends and another begins for easier visualization.

  1. What is looping control flow allowing us to do?
    Looping control allows us to go back to some point in the program and do it all over again,
  2. Describe what “loops” do in your own words.
    It is a way to do large computations in a simple way
  3. What is the difference between while and do-loops?
    Do loops always executed the loop at least once and it starts testing if it should stop after the first try.
  4. What is indentation?
    Indentations are number of spaces in front of statements that make the code visually more readable, they are not necessary but helpful

Loops allow us to run a piece of code multiple times.

For and while loops check the conditions before each iteration (so the loop will only run if the conditions are true), and do-while loops check the conditions after each iteration (so the loop body will run at least once whether or not the conditions are true).

Indentation is adding whitespace to the start of each line of code to make the code easier to read.

1- What is looping control flow allowing us to do?
It allows us to go back somewhere in the program where we were before and repeat with our current program state.

2- Describe what “loops” do in your own words.
The loops are program to repeat a function with values to get result till all required conditions are met.

3- What is the difference between while and do-loops?
Do loops are runs one time till the provided value met with the results.
While loops are runs infinite as long as the result is true and it will stuck in repeating the loop unless you break it with a maximum certain value.

4- What is indentation?
Indentation and making your coding organized and easy to know what is going on by building a structure in the coding, in easy words to understand to make spaces by pressing the TAB in each block so you will know there is a block inside another.

  1. to execute a block of code multiple times
  2. a loop repeatedly executes a block of code for a defined number of iterations.
  3. a while loop executes while a condition is true. A Do loop executes a block of code until a condition becomes true
  4. layout that allows more code readability.