Part 2- A Smarter Way to Learn JavaScript Flashcards
What’s the tool to get input from a website visitor?
Prompt
What’s the format for prompt?
var question1 = prompt(“What is your street’s name?”, “Suggested response”);
How do you suggest an answer for a propmt?
var nameOfVariable = prompt(“Question goes here”, “Suggested answer”);
Which part of a prompt statement has the user’s response assigned to it?
The variable
What does the second argument in a prompt statement mean? Like the X in this:
var redFin = prompt (“Hi”, X );
It’s the suggested response.
What’s the syntax for an IF statement that says, if x = y, then run the code.
if (x === y) {
//code that will be run
}
Note the space between IF and the first parentheses. It’s not required, but is the the accepted style.
What is the best, strictest symbol for “equals”
===
The strict equality ( === ) operator checks whether its two operands are equal, returning a Boolean result.
Unlike the equality operator, the strict equality operator always considers operands of different types to be different.
What are these?
!==
>=
<=
Comparison Operators (aka Relational Operators)
What is the best, strictest symbol for “does not equal”
!==
What’s the difference between an ELSE statement and an ELSE IF statement?
The ELSE statement executes something no matter what. It is not testing anything for truth.
But ELSE IF tests a condition. So it’s like another IF statement that would execute after the previous one failed to.
Can an IF statement test for multiple conditions? If so, how?
Yes, you can test for multiple conditions.
Join them with && for “and”.
You can also join them with || for “or.”
You can avoid ambiguity by grouping conditions with parentheses, like in math.
In an IF statement, what’s the symbol for and?
&&
In an IF statement, what’s the symbol for or?
||
If you have multiple conditions to test in an IF statement, how do you avoid ambiguity?
Use parentheses to group the terms that should go together
If there are several IF statements, does JS go through them all?
No. JS stops testing after the first true one it finds.