DEV Community

lschwarte22348
lschwarte22348

Posted on

Control Flow, Conditonals and Iterations

Introduction

A computer that tells its lines of code to read other lines of code is a simple yet unjustified way of the what's actually behind the code.
It could be so much more but also not. Control Flow is no different than Flexbox or CSS as it also pairs things into ordered lists rather than having non-implanted lines of Code that serve only a functional purpose.

let= console.log arrays elements

What is Control Flow

Statements from a source file a originally place from top to bottom and appear in the order they are perceived but Control Flow Statements can change the order of the flow of the organized list by making decisions creating loops all being supported by The JavaScript Language.

Alt Text

Conditions of a statement are either true or false and are placed in the order in which they match with their placing, Control flow helps decide the placing of all the statements and the Statements follow an exact placing of all that the information is given.

{
first statement;
second statement;
}

Conditional Statements

Called an “if” statement it executes a block of code if the conditional expression inside a pair of parentheses evaluates to true. The conditions typically involve comparison of variables for equality or inequality

Let a = Intro To
Let b = Computer
Let c = Science

These variables can either list numbers or letters in a block and if told to; can change depending on console.log properties which allow for it to be assessed and changed depending on the variables executed by the console.log in a Conditional Statements.

empty array with no elements
Let empty = [];

array with 2 string elements
Let days = ["Computer", "Monday"];

array with elements of different types
Let mixed = [false, 2.70, "Hello"];

elements can be arbitrary expressions
Let suffix = "school";
Console.log school = ["Math" + , "Science" +];

2 dimensional array with object literals
array2 = [[1,{x:1, y:2}], [2, {x:3, y:4}]];

the 3rd element is undefined
Let colors = ["Red", "Blue", undefined];

no value in the 1st element, it is undefined
Let hobbies = [,"Swimming"];

Iteration and Iterations methods in Javascript

A third class of arrays are known as iterations (iteration statements or iteration methods)

Codes or Content that repeat are Iterations, iterations work as Arrays in javascript; objects whose prototype has functions and methods to perform bulk operations, mutations, and traversals.

These Iterations work with java to at any point can acmes the elements of that array, these are referred to as iteration methods which work with conditionals to create the system in which elements are ordered in by array.

Iteration methods, as long with Mutator methods and accessor methods are the most common like arrays found in javascript and can manipulate points of data to fit an array.

empty array with no elements
Let empty = [];

array with 2 string elements
Let days = ["Computer", "Monday"];

array with elements of different types
Let mixed = [false, 2.70, "Hello"];

elements can be arbitrary expressions
Let suffix = "school";
Console.log school = ["Math" + , "Science" +];

2 dimensional array with object literals
array2 = [[1,{x:1, y:2}], [2, {x:3, y:4}]];

the 3rd element is undefined
Let colors = ["Red", "Blue", undefined];

no value in the 1st element, it is undefined
Let hobbies = [,"Swimming"];

Top comments (0)