- Why do we use if/else statements?
- What is the basic syntax of if/else if statements?
- What is the purpose of isNaN?
- How do we evaluate conditions if we have &&? What about ||?
- How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
- Why do we use loops?
- What loop do we use when we want the code to run a specific number of times?
- What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
- What are the three parts of a for loop?
- Which coding language adds structure to a web page?
- Which coding language adds functionality to a web page?
- Which coding language adds design elements to a web page?
- Why is JavaScript event-driven?
Reader Interactions
Comments
Leave a Reply
You must be logged in to post a comment.
1. We use if/else statements because it allows us to run some codes based on whether a condition is true or false.
2. “if” is used to specify a block of code to be executed if the condition is true. You use “else” if the same condition is false. Use “else if” to specify a new condition to test, if the first condition is false.
3. isNaN is a global method and it available everywhere in your JavaScript code.
4. && is used if the first expression and the second expression both evaluate to true. II is used if either the first expression or second expression evaluate to true.
5. “if” is used to specify a block of code to be executed if the condition is true. You use “else” if the same condition is false. Use “else if” to specify a new condition to test, if the first condition is false. An else statement does take a Boolean Expressions.
6. We use loops because it allows codes to be shortened.
7. We use for loop when we want the code to run a specific number of times.
8. We use while loop when we don’t know the specific number of times.
9. A for loop includes initial action, loop-continuation-condition, and action-after-each-iteration.
10. html adds structure to a web page.
11. JavaScript adds functionality to a web page.
12. CSS adds design elements to a web page.
13. JavaScript is event-driven because it reacts to events and it maintains a list of events that happened.
Hello there, Bita.
JavaScript is event-driven because it reacts to events and keeps track of what has happened. It is also used to synchronize the occurrence of several events and to simplify the program.
Hi Bita! I like how easy it was to understand the else/else if basic syntax. Overall I think you answered the questions well.
Hi Bita, I never realized how often IsNaN can be used. I always thought that it was hidden in some areas of Javascript.
Hey Bita,
I totally loved how you delved into the reason why javascript is event-driven. My response was also very similar so I its comforting to see your response!
isNaN Stands for “is not a number”.
HI Bita,
Great job in explaining the difference between if, else, and else/if statements. I had some difficulty understanding this concept and you helped me out.
If else statements help us to test conditions and produce a result accordingly. If the condition is true produce result A and if condition is false, produce result B.
The basic syntax is as follows
If number >5 //code
Else // other code
The isNan function checks whether a given value is “illegal” or not. IsNan stands for Not-A-Number and when checking the value input, the value will either be a number or not a number. If not a number, then the return value is true. If a number, then the return value is false.
When we use &&, we are evaluating whether two statements or conditions are true. If they are both true, then we get a true returned. Otherwise, we get a false return.
With || operator we can get a true returned if either of the two statements or conditions are true but will only get a false if both of the statements are false.
In an if statement the Boolean expression is the statement that you are comparing. In a standard if statement if the expression is true, it runs the code within that statement. If false, then it moves to an else or else if statement that runs in the second block instead of continuing. The false expression of the original if statement is what determines that the else statement is run.
Loops are used to perform repetitive tasks and use conditions to control whether the loop will continue running.
For loops are used to run a code a set number of times.
When we don’t know how many times, we will need to run the loop, we use a while loop which will check the conditions and only repeat the loop while the conditions are true.
Three Parts of a For Loop
1. Initialization
2. Condition
3. Iteration
Web Page Structure – HTML
Web Page Functionality – JavaScript
Web Page Design Elements – CSS
JavaScript is event driven because it reacts to events and these events trigger functions which create more events. A great example is the MagicDates coding challenge which prompts the user to enter the day, then prompts for the month, then prompts for the year, and finally outputs whether this is a magic date or not.
Hello Michelle.
Very well said. An if-else statement is a way of checking something in our code. If else sentences allow us to test situations and generate appropriate results. If the condition is true, generate result A; else, produce result B.
Hey Michelle! I like how when you explained the isNaN, you actually said what it stood for. I also thought when you explained the syntax for the if/else statement, you provided an example of actual code. Overall great post!
Hi Mishelle:
I liked your explanation for the last answer on JavaScript event. You make it seem so simple but I find difficult. I’m not sure what MagicDates coding is but I wonder if it’s easier than JavaScript or more difficult? Hopefully it’s easier. Thanks.
Hello Mishelle,
You had a great example in explaining why JavaScript is event-driven, I also think the challenge calories burn would be another example. Overall you did a great job!!
Hi Michelle,
I thought it was super helpful that you mentioned what isNaN actually stood which helps comprehend what this concept really is. I also liked that you provided an example of how JavaScript is event-driven by talking about MagicDates and what that entails.
Hey Mishelle,
You did a great job explaining the isNaN function and how it works in JavaScript. Nice work.
Hi Mishell, great job in defining all of these. I liked that you added an example as to why javascript is event driven, helped me understand it more. You gave more thorough answers which is very helpful.
Hey Mishelle,
Good job, I liked the way you answered the last question about JavaScript being event based. The example you used helped me to understand it better.
• Why do we use if/else statements?
Answer- An if-else statement is a way of checking something in our code.
• What is the basic syntax of if/else if statements?
Answer- The syntax of the if. Else statement is: if (test expression) { // run code if test expression is true } else { // run code if test expression is false }.
• What is the purpose of isNaN?
Answer- The isNaN () function is used to check whether a given value is an illegal number or not.
• How do we evaluate conditions if we have &&? What about ||?
Answer- If both the first and second expressions evaluate to true, && is utilized. If either the first or second expressions evaluate to true, II is utilized.
• How are if statements different than else-if and else? Does an else statement take a Boolean Expression?
Answer- The conditional expression “if” is used to indicate a block of code that will be run if the condition is true. If the same condition is untrue, you use “else.” If the first condition is false, use “else if” to define a new condition to test. An else statement accepts Boolean Expressions.
• Why do we use loops?
Answer- Because it reduces the length of the code, and it saves time.
• What loop do we use when we want the code to run a specific number of times?
Answer- We use loops in java to run a specific number of times.
• What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
Answer- We use a while loop when we don’t know the specific number of times.
• What are the three parts of a for loop?
Answer- The three parts for loops are
1. Initialization.
2. Condition
3. Action-after-each-iteration.
• Which coding language adds structure to a web page?
Answer- HTML adds structure to a web page.
• Which coding language adds functionality to a web page?
Answer- JavaScript adds functionality to a web page.
• Which coding language adds design elements to a web page?
Answer – CSS adds design elements to a web page.
• Why is JavaScript event-driven?
Answer- because it is used to synchronize the occurrence of multiple events and to make the program as simple as possible.
Hello Satish,
I like the way you structured your response to the questions. It was clear and easy to understands thanks. Great job!!
Hi Satish,
I like your explanation of if, else, and else if. This helped clarify in which case I should use each of them. Great post!!
Hey Satish,
I liked the way you answer your questions. I really liked how you answered the question about the difference in the if and the else and if/else statements.
Hello Satish
I realized we have to aware the difference of If, Else-if, Else when we use basic syntax.
Because these differences results in totally different results.
1. We use if/else statements to help run some code based on whether the condition is true or false.
2. The basic syntax of if/else if statements is if the condition returns true, then the statements inside the body of the “if” statement are executed, then the statements inside the body of “else if” are skipped. If returned false, the statements in the “if” statement are skipped and the “else if” are executed.
3. The purpose of isNaN is a global method and it is available everywhere in the JavaScript code.
4. We evaluate conditions when we have && by evaluating whether two statements or the conditions return as true. If both conditions/statements are true, the && is used. We evaluate conditions when we have || by evaluating whether either of the first or second expression is true.
5. If statements are different from else-if statements because the “if” statement is used to signify if a condition is true. You would use else if the same condition returns false. You would use “else-if” to test a new condition, if the first returns false. The else statement accepts the Boolean expression.
6. We use loops to shorten repetitive code and use the conditions to control whether or not the loop will continue running.
7. We would use the “for loop” to run a code a specific amount of times.
8. We would use the “while loop” when we don’t know how long to run the code for.
9. The three parts of a For Loop is the initialization, Condition, and Action-after-each-iteration.
10. The coding language that adds structure to a web page is html
11. The coding language that adds functionality to a web page is JavaScript
12. The coding language that adds design elements to a web page is CSS
13. JavaScript is event-driven because it reacts to events and continues to record the events occurring.
Hey Brandon:
I like the “While” loop because I find it more efficient to use when you’re not sure how long to run the code and/or for the limitless answers it provides. This way you’re not inputting a ton of lines of code into the program which need to be quadruple checked if there is a problem with the code language.
Brandon,
I liked your response to number 6, regarding why we use loops in code.
Hi Brandon
I’ve heard of HTML but was not aware the exact meaning.
But I learned that HTML gives sturucture to a web site!
To execute alternative code in the situation where the if, and else if conditions return true or false.
Use if to specify a block of code to be executed, if a specified condition is true. Use else to specify a block of code to be executed, if the same condition is false. Use else if to specify a new condition to test, if the first condition is false.
NaN is short for “Not-a-Number”. The isNaN() method returns true if a value is NaN.
&& is used if the first expression and the second expression both evaluate to true. II is used if either the first expression or second expression evaluate to true.
The first form if-if-if test all conditions, whereas the second if- else tests only as many as needed: if it finds one condition that is True, it stops and doesn’t evaluate the rest. In other words: if- else is used when the conditions are mutually exclusive. An else statement can be a Boolean expression.
Loops are control structures used to repeat a given section of code a certain number of times or until a particular condition is met.
“For” Loop is used to repeat a specific block of code a known number of times.
“While Loop” can be used in situations where there is an unknown number.
The keyword For that starts the loop, the condition being tested, and the End For keyword that terminates the loop.
HTML makes up the layout and structure for your website.
JavaScript is a scripting or programming language that allows you to implement complex features on web pages.
CSS is language used for design elements to be added to a web page.
It serves the user with the quickest and most accurate responses and this usually translates into better user experience and business gains.
Hi Anna, I enjoyed reading you’re post, I thought it was very easy for me to understand and it definitely helps with someone who is new and trying to learn more about JavaScript.
Hi Anna,
I agree with your response to how JavaScript is event-driven. It also reacts to events and maintains those list of events that have occurred.
Hi Anna,
I loved reading your responses! They were very well written and accurate. It shows that you really took time in your responses.
Hi Anna, great job on this! It was so easy for me to understand I kind of learned more from your explanations. I agree that javascript serves us with the quickest and most accurate responses.
Hi Anna – I agree with the response to the last question around even-driven. When setup correctly, event driven code helps improve UX which is beneficial to the consumer/audience and also benefits the business or broadcaster.
We use the if/else statement because when the code is run it can base whether the code was a true or false condition.
The basic syntax of it/else statements is when a statement inside the if body is returned true then the code would execute. The statement in the else if would be skipped if the statement is returned false.
The purpose of isNaN is its a that method returns true if a value is NaN. NaN stands for Not-a-Number.
The && operator is used if the first expression and the second expression both evaluate to true. The operator || is used if either the first or the second expression evaluate to be true.
In the first if statement evaluates to true, then the code branches into the first alert. If the first if statement is false, than the code evaluates the else if statement to see if the expressions in it evaluates to a true of false. It repeats until the code reaches the end. If none of the statements have expressions that evaluate to true, the code inside the else block executes. If there is no else block, then the code will just go on to the next set of codes. An else statement can be a Boolean expression.
We use loop in oder to write one code but have it run multiple times instead of rewriting the code over and over again.
The For loop is used when we want the code to run a specific number of times.
The While loop is used when we dod not know the specific number of times.
The three parts of a loop are:
1. Initialization
2. Condition
3. Action-after-each-iteration
The coding language that adds structure to the web page is HTML
The coding language that adds functionally to a web page is JavaScript
The coding language that adds design elements to a web page is CSS
JavaScript is event-driven because it reacts to events and these events trigger functions which create more events.
The reason for why we use if/else statements is because it executes a block of code if a special condition is true.
The basic syntax of if/else statements is (test-expression) {True block of statements}Else{ False block of statements} Statements
The purpose of isNaN is to check whether a given value is an illegal number or not.
If we have &&, then both conditions are true, but if we have II, then only one of the conditions is true,
The else-if and else statements are different because in “If”, the statements inside the if block will execute, In “else”, if the condition is true then the statements inside the if block will execute and if the condition is false then the statements inside the if else block will execute. Else statements do take Booleon expressions.
The reason for why we use loops is because they allow programmers to shorten what could be hundreds of lines of code to just a few.
The kind of loop we use to get the code to run a specific number of times is the “For” loop.
When we don’t know the specific number of times, we use the “While” loop.
The three parts of a for loop are the keyword which starts the loop, the condition that is being tested, and the EndFor keyword that terminates the loop.
The coding that adds structure to a web page is the HTML.
Java script is the coding language that adds functionally to a web page.
The coding language that designs elements to a web page is CSS.
Java script is event driven because it can interact with HTML elements, which are event emitters, that is, subjects able to emit events.
Brian,
I liked the way that you explained the difference between else and if/else statements.
Hi Brian – thanks for your “loops” explanation on why we use them. The way you explained this helped accelerate my understanding of why.
The if/else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed. The if/else statement is a part of JavaScript’s “Conditional” Statements, which are used to perform different actions based on different conditions.
if (condition1) { //These statements would execute if the condition1 is true } else if(condition2) { //These statements would execute if the condition2 is true } else if (condition3)
The isNaN() function is used to check whether a given value is an illegal number or not.
If applied to boolean values, the && operator only returns true when both of its operands are true (and false in all other cases), while the || operator only returns false when both of its operands are false (and true in all other cases).
The purpose of loops is to repeat the same, or similar, code a number of times. This number of times could be specified to a certain number, or the number of times could be dictated by a certain condition being met.
A “For” Loop is used to repeat a specific block of code a known number of times.
A while loop is an iteration method that is best used when you don’t know the number of iterations ahead of time. The contents of the loop are executed as long as the expression evaluates too true.
A For loop consists of three parts: the keyword For that starts the loop, the condition being tested, and the EndFor keyword that terminates the loop.
HTML makes up the layout and structure for your website. This language is dynamic and allows you to create a beautiful website using less code , which is why it is highly recommended by various digital marketing Companies across the globe.
JavaScript is a programming language designed to provide interactive Web content. It is an important component of webpage design. JavaScript is integrated within the HTML code and makes webpages dynamic.
CSS is used hand in hand with HTML to add colors, backgrounds, layouts, font sizes, and more. This language is a core technology web developers use to design and build websites.
JavaScript in the browser uses an event-driven programming model. Everything starts by following an event. The event could be the DOM is loaded, or an asynchronous request that finishes fetching, or a user clicking an element or scrolling the page, or the user types on the keyboard.
Hello tul63769,
This is a great post with lots of detail!! I specifically like your descriptions for HTML, CSS, and JavaScript.
Hi tul63769,
Your responses to the questions are very thought out and detailed. The last explanation for events in JS is easy to understand and grasp.
– We use if/else statements to run a code based on whether a condition is true or false.
– if(expression operator expression) {
do_something;
} else {
do_something_different;
– Isnan is a global method, global means that it is available everywhere in your JavaScript code.
-If the condition contains &&, the first and second expression will both return to be true. If the condition contains ||, either the first or second expression will return to be true.
– If statements differ from if/else statements because they only contain one condition for the code to follow, whereas the if/else statement uses a true/false statement to have the code perform something else if the original condition is not met. Therefore, it would take a Boolean expression.
– We use loops when we want to repeat a code or run an action multiple times.
– You would use the for loop for running a code a specific number of times.
– You would use the while loop for running a code when we don’t know the specified number of times.
– The three parts for a loop are the starting point, the step, and the condition. The starting point is where we declare and initialize our variable. The step is where to specify how the starting point will evolve. The condition is where to determine when the loop will stop running.
– HTML is the coding language that adds structure to a webpage.
– JavaScript adds functionality to a webpage.
– CSS is the coding language that adds design elements to a webpage.
– JavaScript is interactive, which means it waits for the user to do something and then the code is executed. The code is not executed immediately.
Hi Olivia, great work on this discussion post you explained everything pretty well and gave a better understanding.
Hi Olivia,
Great explanation of the conditions for && and || expressions.
Why do we use if/else statements?
– It executes a block of code if a specified condition is true.
What is the basic syntax of if/else if statements?
– if (test-expression) { True block of statements } Else { False block of statements } Statements;
What is the purpose of isNaN?
– Is to check whether a given value is an illegal number or not
How do we evaluate conditions if we have &&? What about ||?
– logical AND (&&) operator for a set of boolean operands will be true if and only if all the operands are true,
– OR (||) is a logical operator in Java that is mainly used in if-else statements when dealing with multiple conditions.
How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
– Use if to specify a block of code to be executed if a specified condition is true. Use else to specify a block of code to be executed, if the same condition is false. Use else if to specify a new condition to test, if the first condition is false.
– Yes, as Boolean is a true/false evaluation.
Why do we use loops?
– They allow them to shorten what could be hundreds of lines of code to just a few.
What loop do we use when we want the code to run a specific number of times?
– “For” loop.
What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
– “While” loop.
What are the three parts of a for loop?
– Keyword “For” to initiate the loop
– The condition being tested
– EndFor keyword that ends the loop
Which coding language adds structure to a web page?
– html
Which coding language adds functionality to a web page?
– JavaScript
Which coding language adds design elements to a web page?
– css
Why is JavaScript event-driven?
– To synchronize the occurrence of multiple events and to make the program as simple as possible.
Hi Thao, great work on this assignment and answering the questions precisely.
JavaScript event-driven because it requires a webpage viewer to click on items on the webpage to further access more of the site.
Hey Thao,
I really like your response for why JavaScript is event-driven. It really does make things as simple as possible! Great stuff!
1. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not.
2. if(expression operator expression) {
do_something;
} else {
do_something_different;
3. The is NaN function is used to check whether a given value is an illegal number or not.
4. Conditions are evaluated when we have && by evaluating whether two statements or the conditions return as true. If both conditions are true, the && is used. We evaluate conditions when we have || by evaluating whether either of the first or second expression is true.
5. If statement is used to specify a block of code to be executed if a specified condition is true. Whereas else if is used to specify a new condition to test, if the first condition is false and else is used to specify a block of code to be executed if the same condition is false. Yes, an else statement takes a Boolean expression.
6. Loops are used in JavaScript to perform repeated tasks based on a condition.
7. A “For” Loop is used when we want the code to run a specific number of times.
8. A “While” loop is used when we don’t know the specific number of times.
9. The three parts of a for loop are initialization, condition, and iteration.
10. HTML coding language adds structure to a web page.
11. JavaScript coding language adds functionality to a web page.
12. CSS (Cascading Style Sheets) coding language adds design elements to a web page.
13. JavaScript is event driven because in the browser uses an event-driven programming model. Everything starts by following an event.
Hey Ashanna,
I liked how you added the actual code of an if/else statement, as did I in my post. I believe that it is important to show how the function would actually look in JavaScript in order to have a better understanding of how it functions.
Well done!
Your answer for 13 was a lot better than my own, my classic problem in school is always I will understand something but I have no ability to pick up content specific buzzwords or phrases.
1. Why do we use if/else statements?
It allows us to run some codes based on whether a condition is true or false.
2. What is the basic syntax of if/else if statements?
If something is true, do something. Else, do something different
3. What is the purpose of isNaN?
Stands for “is not a number”. It get returned when you do some numerical operation that is invalid.
4. How do we evaluate conditions if we have &&? What about?
&&, if the first expression and the second expression both evaluate to true.
||, If either the first expression or the second expression evaluate to true
5. How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
IF is used to execute a set of statements if the condition is true.
ELSE provides an alternative to IF when the same condition is false.
When the condition is false, ELSE IF can be used to execute a new set of statements.
ELSE does take Boolean expressions.
6. Why do we use loops?
When we need to repeat a sequence of instructions until a certain condition is reached.
7. What loop do we use when we want the code to run a specific number of times?
While Loop
8. What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
For loop, since the For Loop will run until the condition is false.
9. What are the three parts of a for loop?
Starting point, condition, and step
10. Which coding language adds structure to a web page?
HTML
11. Which coding language adds functionality to a web page?
Javascript
12. Which coding language adds design elements to a web page?
CSS
13. Why is JavaScript event-driven?
Javascript adds functionality to a webpage. When you go to a webpage, you are able to click on items to access more features. These are events powered by Javascript.
Hi Kevin,
I appreciate that you explained what isNaN stands for. I also like that you explained why we used the for loop for when we do t know the specific number of times.
Hey Kevin,
I really like your answer for how if statements are different from else if statements. It really helped me. Thank you for sharing!
Hi Kevin,
Great explanation on describing the difference between if statements & else-if and else.
1. We use if/else statements in order to run code based on whether a condition is true or false.
2. The basic syntax of if/else statements is: if (expression operator expression) {
do_something;
} else {
do_something_different;
}
3. The purpose of isNaN is to check whether a given value is an illegal number or not.
4. The && operator is used if the first expression and the second expression both evaluate to true. The II operator is used if either the first expression or the second expression evaluates to true.
5. The if statement is used to specify a block of code to be executed if a condition is true. The else statement is used to specify a block of code to be executed if the condition is false. The else/if statement is used to specify a new condition if the first condition is false. An else statement takes boolean expressions.
6. Loops are a sequence of instructions that are repeated until a certain condition is reached.
7. We use the for loop when we want the code to run a specific number of times.
8. We use the while loop when we don’t know the specific number of times.
9. The three parts of a for loop are the declaration and initialization of a number, the condition being tested, and the EndFor keyword that terminates the loop.
10. HTML adds structure to a webpage.
11. JavaScript adds functionality to a webpage.
12. CSS adds design elements to a webpage.
13. JavaScript is event-driven because it is interactive. It waits for the user to do something and then executes code.
Hi Molly,
I like how you included the additional elements of a for loop, such as the keyword. Also I like the way you described javascript as interactive and user-driven.
* Why do we use if/else statements?
If/else statements execute a block of code if a specified condition is true. This helps us use a function without having to copy it over and over. Instead, it’ll loop through each condition and test.
* What is the basic syntax of if/else if statements?
the syntax of an if/else statement is as follows: if (“expression operator expression”) {
do_something ;
} else {
do_different
* What is the purpose of isNaN?
isNaN checks whether or not a variable is a number. It is a global method.
* How do we evaluate conditions if we have &&? What about ||?
&& evaluates if both conditions are true. They both must be true for true expression to be true. || is used if either the first or se one condition is true. If either one is true, the return will be true.
* How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
The if statement doesn’t give an alternative statement for false, so when the condition is false, the program simply skips to the next code block. If it is true, the code is executed.
Meanwhile, the else statement provides a second code black: a statement for true (if) and false(else). if the expression is true, the first block is execute; if it is false, the second block is executed.
The else-if statement adds a second condition to check if the first condition is false.
* Why do we use loops?
Loops are used to run a block of code over and over again. They specify the code we want to repeat and when to stop.
* What loop do we use when we want the code to run a specific number of times?
For loop
* What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
While loop
* What are the three parts of a for loop?
The initialization, such as i=0, the condition, such as i<=7, and the iteration, such as i++.
* Which coding language adds structure to a web page?
HTML
* Which coding language adds functionality to a web page?
Javascript
* Which coding language adds design elements to a web page?
CSS
* Why is JavaScript event-driven?
Javascript starts with an event and continues its actions based of said event.
Hi Cassadi, you explained how the if statements different then else-if and else well. The if statement does not give an alternative. Thank you!
We use if/else statements to run the code to in order to see us the conditions are true or false
The basic syntax of if/else statements is you use if to block a code to be executed if the condition is true and else if used to block a code to be executed if the condition is false.
This stands for Not-A-Number. The purpose of isNaN is to check if the function is legal or not. Value is either true or false, if its a number its false and not a number is true.
We evaluate conditions if we have && by the first and the second expression being true and II if either the first expression or second one is true.
The if is used if a condition is true and if the same condition is untrue then it will be else. If the first condition is false then the else/if will be used. The else statement is what takes the boolean expression.
We use loops because they will perform repetitive takes making the codes shorter.
We use the for loop to run a code specific amount of times
We will use the while loop when we don’t know how long to run the code for
The three parts of a for loop are; initialization, condition, and action
The coding language that adds structure to a web page is html
The coding language that adds functionality to a web page is Javascript
The coding language that adds design elements to a web page is CSS
Javascript is event driven because it reacts(and lists) to the events and that triggers functions which creates more events.
Hi Adelina, I like how you explained the purpose of isNaN. This is to check if the function is legal or not and if it’s a number.
Hi Adelina! I totally agree with why loops are much more efficient in performing repetitive tasks, when I was first learning JavaScript I found the loops hard to grasp at first but in the end it makes things so much easier to keep c0de clean, organized and efficient.
Why do we use if/else statements?
– These statements allow you to run code based on wether a condition is true or false.
What is the basic syntax of if/else if statements?
– If condition returns true then the statements inside the body of “if” are executed and the statements inside body of “else” are skipped. If condition returns false then the statements inside the body of “if” are skipped and the statements in “else” are executed.
What is the purpose of isNaN?
-This is a global method. This is available everywhere in the Javascript code. This is also called a function sometimes. This will verify is a variable is a number.
How do we evaluate conditions if we have &&? What about ||?
-&& is used to perform and operation means if anyone of the expression/condition evaluates to false whole thing is false. || is used to perform or operation if anyone of the expression/condition evaluates to true whole thing becomes true.
How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
– If is used to specify a block of code to be executed, if a specified condition is true. Else-if is used to specify a new condition to test, if the first condition is false. An else statement takes boolean expressions.
Why do we use loops?
– We use loops when we need a solution for repeating code with control over how many times the code repeats.
What loop do we use when we want the code to run a specific number of times?
– For loop
What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
– While loop
What are the three parts of a for loop?
-Initialization, Condition Checking, and iteration : increment or decrement
Which coding language adds structure to a web page?
-HTML
Which coding language adds functionality to a web page?
-Javascript
Which coding language adds design elements to a web page?
-CSS
Why is JavaScript event-driven?
-It is interactive, It waits for the user to do something and then executes the code.
Hey Anthony,
You made a great point about the fact that the iteration part of a for loop can either be an increment or decrement. Overall, your responses were organized and well-worded.
Great job!
Hi Anthony, great responses.
Hi Anthony, I really liked how you explained && and || it was really clear!
– We use if/else statements in order to run code based on whether a condition is true or false.
– The basic syntax of if/else statements is that if the condition returns true, the statements in the “if” body are executed, and if the condition returns false, the “if” statements are skipped over and the statements in the “else” body are executed. In JavaScript, it would look something like this:
if (something_is_true) {
do_something;
} else {
do_something_different;
}
– The purpose of the isNaN function is to check whether or not a given value is a number, with NaN standing for Not-A-Number. This function is a global method, meaning that it is available everywhere in your JavaScript code.
– If we have &&, it is only true if the first expression and the second expression both evaluate to true. If we have ||, it is true if either the first expression or the second expression evaluate to true.
– If statements are different than else-if and else statements because if the condition returns true, the “if” body statements are executed. If the condition returns false, the “else-if” body statements are executed. If both of these conditions return false, then the “else” body statements are executed. An else statement does in fact take a Boolean expression.
– We use loops in order to repeatedly execute code until a desired condition is reached.
– We use a for loop when we want the code to run a specific number of times.
– We use a while loop when we don’t know the specific number of times.
– The three parts of a for loop are the initial action, the loop continuation condition, and the action after each iteration.
– The HTML coding language adds structure to a web page.
– JavaScript adds functionality to a web page.
– CSS adds design elements to a web page.
– JavaScript is event-driven, aka interactive, because of the fact that it waits for the user to do something and then executes code.
Hi David, great answers. I liked that you gave an example of the if/else statement.
Hey David, your post was very detailed, and I appreciate that. It helps me understand the concepts of programming. I am not the only one that finds programming difficult. Your explanations of each made it clear to me. Great job explaining about if statements and if-else statements, I had trouble with that and your explanation helped me out.
1. We use if/else statements when the expression evaluates to a true or false.
2. The basic syntax of if/else statements is “if” is used if the condition is true. “Else” is used when the condition is false.
3. The purpose of isNaN is to check whether a given value is an illegal number or not.
4. We evaluate the conditions “&&” when the first expression and the second expression both evaluate too true. For “||” either the first expression or the second expression evaluates to true
5. If statements are different from else-if and else are used as a block of code to be executed if a specified condition is true. Else are used as a block of code to be executed if the same condition if false. Yes, the else statement does take a Boolean Expression.
6. We use loops to repeat a code with control over how many times the code repeats.
7. For loop is used when you want code to run a specific number.
8. While loops are used when we don’t know the specific number of times.
9. The three parts of a loop are initialization, condition, and iteration.
10. HTML adds structure to a web page.
11. JavaScript adds functionality to a web page.
12. CCS adds design elements to a web page.
13. JavaScript is event-driven because it’s occurrence of multiple events and makes the program simple as can be.
Hi Jessica! I liked how you explained the &&/|| operators and conditions. I had a bit of trouble understanding them at first as it sometimes feels like there are so many and it is easy to get them mixed up when writing and running code.
Hi Jessica, your answers were really precise and to the point. It makes it easy to review all questions, good job!
Hey Jessica, good job with this post. You did a great job explaining the differences between if statements and else-if statements. Before, I had some trouble with the two statements. I learned that those statements are key components to the software javascript.
Why do we use if/else statements?
– We use if/else statements to perform actions based on if input conditions are true or false.
What is the basic syntax of if/else if statements?
– if/else statements have 2 sections, the if part filled in for if the statement is true, and if false, the else section to perform a different action.
If (condition is true) {
Do_something
} else {
do_something_else
}
What is the purpose of isNaN?
– The global method isNaN() boolean returns inputs as true or false. It being global means it is available in JavaScript everywhere.
How do we evaluate conditions if we have &&? What about ||?
– If we have the and (&&) operator, we can evaluate if the first and second expression evaluate to true. If we have the or (||) operator, we can test if either the first or second expression evaluates to true.
How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
– If statements are good for testing but Else-if statements to test for more complex situations than an if statement. Else statements can take Booleans to evaluate true and false.
Why do we use loops?
– Loops can help clean repetitive code up and make it cleaner, easier and more efficient to repeat actions.
What loop do we use when we want the code to run a specific number of times?
– To get a code to run a specific number of times, we use the ‘for’ loop to run for a specific duration.
What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
– If we don’t know the specific number of times, we use the ‘while’ loop to run while a condition is true.
What are the three parts of a for loop?
– A for loop uses the keyword, the condition the loop needs to test for and the key that terminates the loop. The for loop takes 3 parts; introducing a variable, the condition of the loop, and an increment.
Which coding language adds structure, functionality and design elements to a web page?
– HTML adds structure, JavaScript adds functionality, and CSS adds elements to a webpage.
Why is JavaScript event-driven?
– JavaScript is event driven because it follows a list of multiple events to execute the code.
1. If and Else statements allow you to run some code based on whether a condition is true or false.
2. The syntax of the if statement is If (condition- 1) {statements}
{else if (condition- 2) {statements}
An if Statement with an else clause
alert (“You may vote.”);
If (age>= 18) {
alert (“you may vote’);
} else {
Alert (“You are not old enough to vote.”);
}
3. Three parts of a for loop is the keyboard For the starts the the condition being tested, and the EndFor keyboard that terminates the loop.
4. With an if statement, a program will execute the true code or nothing, With the if/else statement, the program will execute either the false code block statement. Yes, an else statement takes a Boolean Expression.
5. By using loop, we repeat codes many times.
6. We use A For Loop when we want the code to run a specific number of times.
7. We use while loop when we don’t know the specific number of times.
8. HTML adds structure to a webpage.
9. JavaScript adds functionality to a web page.
10. CSS adds design element to a web page.
11. JavaScript is event- driven because it reacts to events. I n addition, it allows you to add an event when a task is finished, allowing to run asynchronously
12. The isNaN function is used to check whether a given value is an illegal number or not. isNaN (is a global method.
13. If we see && it’s either the first expression or the second expression evaluates to true. For II if it’s the first expression or the second expression evaluate to true
Hi Robert
Great job explaining the structure, functionality, and design of a webpage. I also liked your simple breakdown of loops.
If/else statements are used to determine if something is true or false. The basic syntax of if/else statements are {if…() else ()}. The purpose of isNaN is to return true if a value is Not A Number. Conditions involving && are used if the first and second expressions are true. II is used if one of the 2 expressions are true. Else-if statements are used to give more than one true expression. They are different than if-else statements because those read only true or false. We use loops to create a cleaner look for repeating code. Using a for loop is best when we want code to run a specific number of times. Using a while loop is best when we do not know the specific number of times we want an expression. The three parts of a loop include initialization, condition checking, and the statement. Coding language that adds structure to a web page is called HTML. The coding language that adds functionality to a web page is called JavaScript. Coding structure that adds design elements to a web page is called CSS. JavaScript is event-driven because it reacts to events and keeps a list of events that have happened.
Q:Why do we use if/else statements?
A: If/Else statements allow us to run codes based on meeting certain criteria.
Q: What is the basic syntax of if/else if statements?
A: 1 Let action = true;
A: 2 if (action) {
A: 3 alert (“command if”);
A: 4 } else {
A: 5 alert (“command else”);
A: 6 }
Q: What is the purpose of isNaN?
A: IsNaN allows tests to be performed for values that are not a number.
Q: How do we evaluate conditions if we have &&? What about ||?
A: The && operand requires both statements to return true and resonds false immdediately once any condition is not satisfied. || replaces AND with OR.
Q: How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
A: Else statements do take boolean expressions.
A: Else allows for code to consider more criteria to decide which tasks to perform and values to return.
Q: Why do we use loops?
A: Loops allow us to execute specific tasks that repeat based on conditions.
Q: What loop do we use when we want the code to run a specific number of times?
A: We use a “For” loop to execute code a specific number of times.
Q: What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
A: We use a “While” loop to execute code when we don’t know how many times it needs to run.
Q: What are the three parts of a for loop?
A: Initialization, Condition, Iteration
Q: Which coding language adds structure to a web page?
A: HTML
Q: Which coding language adds functionality to a web page?
A: JavaScript
Q: Which coding language adds design elements to a web page?
A: HTML
Q: Why is JavaScript event-driven?
A: JavaScript interacts with HTML and responds to events that trigger further events. This allows simplicity for the UX.
I like your formatting for the questions with your Q/A form, probably should have done that from the start on my own posts instead of always having to scroll back and forth and just input the answers.
Nice and clean post, good job Ross 🙂
Hi Ross, I like the detail that was included in your post, especially for question 2 where you detailed the syntax of if/else statements.
Hey Ross
Something that stood out to me the most was the way you set up your if/else statements and how they are properly used. I also thought that HTML adds design elements to a web page, but it looks like some people wrote CSS.
Why do we use if/else statements?
We use If/Else statements because it allows the user to run codes based on whether it’s true or false
What is the basic syntax of if/else if statements?
The basic syntax of it/else statements is when a statement inside the of body is returned true this will cause the code to execute. The statement in the else if would be skipped if the statement is returned to be false.
What is the purpose of isNaN?
This is used everywhere in javascript, this is also used globally. This function will verify if a variable is a number.
How do we evaluate conditions if we have &&? What about ||?
We can evaluate both by knowing that (&& ) operand requires both statements to return true right away. || is used when either the first expression or the second expression evaluates to true
How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
the statements are all different because (IF) is used to execute a set of statements if the condition is true. (ELSE) provides an alternative to IF when the same condition is false. When the condition is false, (ELSE IF) can be used to execute a new set of statements. And, (ELSE) does take Boolean expressions.
Why do we use loops?
Loops can help keep everything hygienic by preventing repetitive codes, it also makes it easier and more efficient to repeat actions.
What loop do we use when we want the code to run a specific number of times?
We use a for loop when we want the code to run a specific number of times.
What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
We use the While Loop when we don’t know the specific number of times
What are the three parts of a for loop?
the three parts of a for loop is 1.) starting point, 2.) condition, and 3.) step
Which coding language adds structure to a web page?
HTML is the coding language that a user uses to add structure to a web page
Which coding language adds functionality to a web page?
Javascript is the coding language that adds functionality to a web page.
Which coding language adds design elements to a web page?
CSS adds design elements to a web page.
Why is JavaScript event-driven?
Javascript is event driven because it reacts to events and these events trigger other functions which then creates even more events.
Joanna,
I liked you responses I thought they were really informative and you answered them well.
If / else statements are used to run code based on whether a condition is true or false. The basic syntax in code is that “(if-something_is_true) then it will {do_something}. The isNaN function is used to check whether a given value is an illegal number or not. The expression should be true if the value is a NaN, otherwise it returns false. It is different from the Number. To evaluate the conditions for && the first and second condition both have to be true. For ||, only the first or second expression evaluated has to be true. We use two if statements if both if statement conditions could be true at the same time, while an if/else statement is only used if the two conditions are mutually exclusive, meaning if one condition is true the other condition must be false. The if/else is like a fork in the road. Under the control of the boolean test, one or the other will be taken, but not both. The purpose of loops is to repeat the same, or similar, code a number of times. To loop through a set of code a for a specific number of times, you can use the range() function, which returns a list of numbers starting from 0 to the specified end number. Similar to a “While” loop, a “For” loop consists of three parts, the keyword “For” that starts the loop, the condition being tested, and the “EndFor” keyword that terminates the loop. On the other hand, JavaScript is a programming language designed to provide interactive Web content. It is an important component of webpage function. CSS is the language developers can use to design a website. The style sheet language describes how your website is presented and its format. CSS is used hand in hand with HTML to add colors, backgrounds, layouts, font sizes, and more. Event-driven programming serves the user with the quickest and most accurate responses and this usually translates into better user experience and business gains. Everything starts by following an event.
Q: Why do we use if/else statements?
A: Is/else format creates guidelines for code to run and helps things run as intended.
Q: What is the basic syntax of if/else if statements?
A: Allowing or blocking a line of code to run requiring it meets specified criteria beforehand.
Q: What is the purpose of isNaN?
isNaN checks that a value is not an illegal number.
Q: How do we evaluate conditions if we have &&? What about ||?
&& checks from left to right for false operands returning with the false operand,
|| changes the and criteria to or.
Q: How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
Else statements do no take boolean expressions, and else creates a wider range of acceptable values to return.
Q: Why do we use loops?
Loops help keep coding clean and reduce the amount of code needed for something that may run multiple times.
Q: What loop do we use when we want the code to run a specific number of times?
“for loop”
Q: What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
While loop
Q: What are the three parts of a for loop?
The three parts of a for loop are initialization, condition, and iteration.
Q: Which coding language adds structure to a web page?
HTML
Q: Which coding language adds functionality to a web page?
JavaScript
Q: Which coding language adds design elements to a web page?
HTML
Q: Why is JavaScript event-driven?
Javascript is event driven meaning when it receives an input it reacts to the event.
I like the point that you made about loops helping to simplify the code- it definitely adds up and can become confusing without a loop.
• The if statement to specify a block of JavaScript code to be executed if a condition is true. The else statement to specify a block of code to be executed if the condition is false.
• Use if to specify a block of code to be executed, if a specified condition is true. Use else to specify a block of code to be executed, if the same condition is false. Use else if to specify a new condition to test, if the first condition is false.
• The isNaN() function determines whether a value is NaN or not.
• In the logical AND (&&) operator, if both conditions are true, then the if block will be executed. If one or both of the conditions are false, then the else block will be executed. In the logical OR (||) operator, if one or both of the conditions are true, then the code inside the if statement will execute.
• The if/else statement extends the if statement by specifying an action if the if (true/false expression) is false. With the if statement, a program will execute the true code block or do nothing. With the if/else statement, the program will execute either the true code block or the false code block, so something is always executed with an if/else statement.
• The purpose of loops is to repeat the same, or similar, code several times.
• A “For” Loop is used to repeat a specific block of code a known number of times.
• The while loop is used to repeat a section of code an unknown number of times until a specific condition is met.
• Initialization, condition, and iteration.
• HTML
• JavaScript
• CSS
• It reacts to events.
-Why do we use if/else statements?- If/Else statements can allow us to evaluate an expression based on if the condition is true or false.
-What is the basic syntax of if/else if statements?- “If” a condition is true, then the code will take a specific action. “Else” the condition is false, another action will be taken.
-What is the purpose of isNaN?- isNaN can tell us if a value is a number or not. It is returned as true if the value is not a number.
-How do we evaluate conditions if we have &&? What about ||? If both operands are true, && is used. If the first operand is true, the evaluation is ended and II is used.
-How are if statements different then else-if and else? Does an else statement take a Boolean Expression? If statements are used for true statements, else is used for false statements, and else-if is used when a statement is false and you need to move on to the next condition. Else statements do take a Boolean Expression because it is part of the “false” aspect.
-Why do we use loops?- We use loops to repeat instructions until a specific condition is reached.
-What loop do we use when we want the code to run a specific number of times?- We use the “for” loop to run a code a specific number of times.
-What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)- When the code is being run an unknown amount of times, we use the “while” loop.
-What are the three parts of a for loop?- The three parts of a for loop are initialization, condition, and iteration.
-Which coding language adds structure to a web page?- HTML is used to add structure to a web page.
-Which coding language adds functionality to a web page?- Javascript adds functionality to a web page.
-Which coding language adds design elements to a web page?- CSS adds design elements to a web page.
-Why is JavaScript event-driven?- Javascript is events-driven because it bases the web page’s features off of specific instructions, and combines these “events” to create a cohesive and working page.
Hi Oceana!
I thought that HTML adds design elements to a web page! Im thankful I scrolled across your post! Great answers and thanks for making them so easy to follow!
-if/else statements are used in order to make a function do something different unless certain criteria are met.
-the basic syntax for if/else is if (condition) {do something} else (condition not met) {do something else}
-isNaN is used to check if a number is an illegal number or not. isNaN stands for is not-a-number
-&& is used if both the expressions evaluate to true. || is used if either expression evaluates to true
-You use if to execute a block of code if a specified condition is true. You use else to execute a block of code if that same condition evaluates as false. You use else if to specify a new condition to test if the first condition is false
-Loops are used in order to save time
-The for loop is used when we know how many times the loop has to be run.
-The while loop is used when we don’t know how many time the loop has to be run.
-The three parts of a for loop include initialization, condition, and iteration
-The coding page that adds structure to a page is HTML
-The coding page that adds functionality to a page is JavaScript
-The coding page that adds design elements to a page is CSS
-Javascript is event based because it reacts to events and keeps a record of every event happening.
Zachary,
Your answers look spot on to me, that’s what I also got.
Kelli
Zachary,
Good job on your answers. They were informative and it shows that you know what you’re talking about.
1.We use it to execute a block of code, but it is a “conditional” statement.
2.“if” is true, “else” is false, “if/else” is to test
3. isNaN determines whether a function is Nan(Not a Number) or not
4.&& is used if the firs expression and the second expression both evaluate to true and || is used if either the first or second expression evaluate to true.
5. An “else” doesn’t need a condition where “else if” is still an if so it does. I think else if is a Boolean because IF condition.
6. We use them to make a task faster and be more accurate.
7. A “For” loop would be used
8. We use the “while” when you don’t know the number of times specifically
9. Initialization, Condition, Iteration
10. HTML adds structure
11.Java adds functionality
12.CSS adds design elements
13. Because it was designed to take action after action and keep responding to these actions.
1. Why do we use if/else statements?
The statements only allows you to run a code established on whether a condition is true or false.
2. What is the basic syntax of if/else if statements?
If the condition is true, then the statements inside “if” are executed, while those in “else” are not. On the other hand, if condition is false, then the statements inside “if” are skipped, while those in “else” are executed.
3. What is the purpose of isNaN?
The function isNaN stands for Not-A-Number. It’s used to check if a function is legal or not. If its value is true or false, then its not a number.
4. How do we evaluate conditions if we have &&? What about ||?
The && is used if the first and second expressions both indicate that they are true, then the II operator is used.
5. How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
The if and the else statements specify a block of code to execute if a condition is true or false. The latter is used to specify a new instance of code if the condition is false. A boolean expression is used in the else statement.
6. Why do we use loops?
Loops are simply just a sequence of instructions that can be repeated until a definite condition is reached.
7. What loop do we use when we want the code to run a specific number of times?
We use the “for loop”, when the code is being runned in a specific number of times
8. What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
With the “while loop”, we would not know the specific number of times.
9. What are the three parts of a for loop?
A for loop is composed of three parts: the declaration, the test, and the endFor. The endFor statement is used to close the loop.
10. Which coding language adds structure to a web page?
HTML adds the form to a webpage.
11. Which coding language adds functionality to a web page?
JavaScript adds functionality to a webpage
12. Which coding language adds design elements to a web page?
CSS adds the design elements towards a web page
13. Why is JavaScript event-driven?
Javascript is a type of application that can add functionality to a web page. When you navigate through a page, it displays various features and allows you to interact with them.
Hi Adam,
Your post is easy to read and follow. I like how you explained exactly what NaN stood for. I also like how you were to the point with your answer for question 2.
1) Why do we use if/else statements?
a. If/else statement is used to run a code based on whether a condition is true or false.
2) What is the basic syntax of if/else if statements?
The basic syntax statement is: if (expression operator expression) {
do_something;
} else { do_something_different; }
3) What is the purpose of isNaN?
a. isNaN function is used to check if a number is illegal or not.
4) How do we evaluate conditions if we have &&? What about ||?
(&&) is a logical operator – will be true if both expressions evaluate to true.
( || ) is a logical operator – if either the first or second expression evaluate to true.
5) How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
a. If statements are used to execute a set of statements if the condition is true. Else-if statements are used to execute a new set of statements. Else statements provide an alternative to IF statements when the same condition is false . Else statements take a Boolean Expression.
6) Why do we use loops?
a. We use loops because it allows codes to be shortened.
7) What loop do we use when we want the code to run a specific number of times?
a. “for” loop
8) What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)]
a. “While” loop
9) What are the three parts of a for loop?
a. The keyword “for” that starts the loop, the condition being tested, and the EndFor keyword that terminates the loop.
10) Which coding language adds structure to a web page?
a. HTML
11) Which coding language adds functionality to a web page?
a. JavaScript
12) Which coding language adds design elements to a web page?
a. CSS
13) Why is JavaScript event-driven?
a. JavaScript is event-driven because it’s interactive and adds more functions.
Why do we use if/else statements?
If Else statements allows javascript to properly carry out a block of code if the specified condition is true.
What is the basic syntax of if/else if statements?
If XXXX (would execute if true)
else if XXXXX
What is the purpose of is NaN?
To see if the number is an actual value or not.
How do we evaluate conditions if we have &&? What about ||?
The && operand requires both statements to return true, while || is only used when either the first or the second expression is true.
How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
If else statements differ from if statements because they allow the statement to be extended by specifying an action. Else statements do take a boolean expression.
Why do we use loops?
Loops are to perform repeated tasks based on a certain condition.
What loop do we use when we want the code to run a specific number of times?
A for loop.
What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
A while loop.
What are the three parts of a for loop?
The keyword that starts the loop, the condition to be tested, and the termination keyword.
Which coding language adds structure to a web page?
HTML
Which coding language adds functionality to a web page?
JavaScript
Which coding language adds design elements to a web page?
HTML
Why is JavaScript event-driven?
JavaScript is event driven because it reacts to events. It makes problem solving as easy as possible.
Hi Stefanie,
I find it interesting how boolean statements play important parts in functions.
Hi Stefanie,
Great answers. All of our answers are pretty much the same except for the 2nd to last question. I said CSS is the coding language that adds design to a webpage.
If else statements are used to run codes base on whether a condition is true or false.
The syntax “if” specifies a block of code to be executed if the condition is true. The syntax “else” is used if the same condition is false. A “else if” syntax is used to specify a new condition to test if the first condition is determined to be false.
The purpose of the isNaN function is to check whether a given value is invalid or not. It stands for not-a-number.
The && conditions are for evaluating whether two statements or conditions are true. If both are true, then we receive the true result. Or else it would be a false result. On the other hand the || conditions are used for evaluating if either of the two statements are true, but only receive a false result if both the statements are false.
Conditional expression “if” indicates a block of code which is run if a condition is true. If the condition is untrue, use “else.” If the original condition is false, use “else if” to define new conditions to test. An else statement accepts Boolean Expressions.
Loops are used to shorten repetitive code and its conditions are used to control whether or not the loop will continue running.
The “for loop” is utilized to run code a specific number of times.
A “while loop” is used when a set amount of loops are not determined.
Three parts of a “for loop” are – Initialization, condition, and action after each iteration.
HTML is the coding language which adds structure to a web page.
JavaScript is the coding language which adds functionality to a web page.
CSS is the coding language which adds design elements to a web page.
JavaScript is event-driven because it reacts to events and these events trigger functions which generate more events.
Hi Raj, I like the detail/ explanation you added to responding to syntax.
1. Why do we use if/else statements?
We use if/else statements to execute codes based on assumptions if a condition is true or false.
2. What is the basic syntax of if/else if statements?
“If” is used to execute a code if the condition is true.
“Else” is used to execute a code if the condition is false.
“Else if” is used to execute a new condition if the prior condition was false
3. What is the purpose of isNaN?
isNan is a universal JavaScript code that is available everywhere
4. How do we evaluate conditions if we have &&? What about ||?
$$ is used if both the 1st and 2nd expressions are true.
II is used if 1st or 2nd expressions is true
5. How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
“If” is used to specify codes if the condition is true.
“Else”is used if the condition is false.
“Else if” is used to specify a new condition if the prior is false.
An else statement take a Boolean Expressions
6. Why do we use loops?
Loops are used because codes can be shortened
7. What loop do we use when we want the code to run a specific number of times?
for loop
8. What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
While loop
9. What are the three parts of a for loop?
Initial action, loop-continuation-condition, and action-after-each-iteration
10. Which coding language adds structure to a web page?
Html adds struction to a web page
11. Which coding language adds functionality to a web page?
JavaScript adds functionality to a web page
12. Which coding language adds design elements to a web page?
CSS adds design elements to a web page
13. Why is JavaScript event-driven?
The reason is that JavaScript reacts to events and it maintains a list of events that have happened.
• Why do we use if/else statements?
– You can use else statements if a condition is true, and if statement when a condition is false.
• What is the basic syntax of if/else if statements?
– The basic syntax, would be that condition1 will execute if condition one is true, then else would be used and executed if condition2 is true.
• What is the purpose of isNaN?
– The purpose of isNaN() in javascript is so check if a value is an illegal number or not.
• How do we evaluate conditions if we have &&? What about ||?
– && means both conditions are true
– || either condition 1 or 2 will come back true
• How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
– If the condition is true, you use the if statement
– If the condition is false, and you want to execute another one, you use an else statement
• Why do we use loops?
– To repeat and or run a code multiple times
• What loop do we use when we want the code to run a specific number of times?
– You would use a For loop
• What loop do we use when we don’t know the specific number of times?
– You could use a while loop
• What are the three parts of a for loop?
– Key word: starts the loop
– Condition: what is being tested
– EndWhile key word: stops the loop
• Which coding language adds structure to a web page?
– HTML
• Which coding language adds functionality to a web page?
– JavaScript
• Which coding language adds design elements to a web page?
– CSS which can be used with HTML
• Why is JavaScript event-driven?
– Because it is able to interact with other functions.
• Why do we use if/else statements?
We use statements to solve different actions based on their conditions.
• What is the basic syntax of if/else if statements?
If the condition is true.
If the specific statement is true.
• What is the purpose of isNaN?
The purpose is to determine whether or not the value is an illegal number.
• How do we evaluate conditions if we have &&? What about ||?
If the first or second expressions is true.
• How are if statements different then else-if and else? Does an else statement take a Boolean Expression?
Use if to block of code to be executed, if specified condition is true. Else statement takes a Boolean expression when it’s false.
• Why do we use loops?
To perform repeated tasks based on a condition.
• What loop do we use when we want the code to run a specific number of times?
When we want the code to run a specific number of times we use “for” loop.
• What loop do we use when we don’t know the specific number of times? (consider the difference between a while loop and a for loop?)
When we don’t know the specific number of times we use the “while” loop.
• What are the three parts of a for loop?
The three parts are initialization, condition and iteration.
• Which coding language adds structure to a web page?
HTML
• Which coding language adds functionality to a web page?
JavaScript
• Which coding language adds design elements to a web page?
CSS
• Why is JavaScript event-driven?
To make the program as simple as possible.