Digital Tech and Innovations Writing Conditional Code Test Flashcards
What is a block of code?
Code after an if statement in curly brackets
What are curly brackets?
What contains a block of code
what are parenthisis, brackets and curly brackets
()
[]
{}
What sign do you use to say something is equal
== two equal signs
What is “the if statement”
a desicion making statement
How do you write a if statement?
if(a > b)
{
}
Can you put an if statement in another if statement?
Yes
What is an else?
If it doesent follow the original if statement, direct it to this other block of code.
Can you have more then one else in an if statement?
No
How do if, else if, else statements work? ex
We start at the first statement, execute it then go to the next and next and so on. You start by asking the user a question. Then we input questions in the code (the if statement), if its this, do this, if its this, do this. We would right multiple if or if else statements that will provide all output options. The code runs through every option until it finds one that matches the input.
ex
if(a > b)
{ document.write(“result 1”) }
else if(a < b)
{ document.write(“result 2) }
else(a==b)
{ document.write(“result 3) }
How do you make more then one if statement?
If else
what is if else? ex
it asks a different question, for another outcome
ex
if(a==b)
{do this}
else if(a<b)
{do this}
what is a strict equality operator and what does it do?
its an operator that makes sure that the values and types of strings are the same. Ex 123 == “123”
what is a comparasin operator
compares its operands and returns a logical value based on whether the comparison is true. =< => etc
What are logical operators
Logial operators are operators where it checks for two true things at once