Answer the following questions about JavaScript. These questions may require you to do your own research to determine the best answer.
Developer Resources
JavaScript is the programming language of HTML and the Web. So JavaScript is the tool to manipulate web pages, perform actions, animate and style the web page visualization through its language. It is JavaScript's responsibility to fulfill the web mapping and visualization.
Variables are used to store information to be referenced and manipulated in a function.They also provide a way of labeling data with a descriptive name, so the function can be easy to understood.
For example, y = 2x + 1, in which x is a variable that can be any number, and the other variable y will change its values correpsonding to x.
Another example is as below:
A = 2; B = 20; C = 200; Define a varibale D equals to the sum of A, B, C. In this case, D is a variable that we used to represent for the sum of values listed before.
x == 10
Firstly, = means define the variable as something, which is changeable.
Secondly, == means that set the variable equal to a fixed value, which cannot be changed.
Thirdly, === is used to compare two values, the return value is True or Fales.
It will return an error since JavaScript cannot add two values with different styles. As for this example, "Hello" is a string type, but 10 is int value, so when print "Hello" +10, it will return an error.
In reality, there are a lot of situations that happened duplicated or there is loop relationship inside. Thus, Loop is used to shorten and simplify the writing of coding, but could also achieve the same result. It is a sequence of instructions that is continually repeated until a certain condition is reached.
For loop is used to repeat a specific block of code a known number of times. The advantage to a for loop is we know exactly how many times the loop will execute before the loop starts.
The while loop loops through a block of code as long as a specific condition is true. If the condition given is always true, the loop won't stop and will continue execute unless close the window.
The three conditional statements are 'if', 'else if', and 'else'. To be specific, use 'if' to specify a block of code to be excuted, if a specific condition is true. For example, if (n=10){s=n+1}. On the hand, use else to specify a lock of code to be excuted, if the same condition is false. For example, if (n=10){s=n+1}; else {s = 10}. Lastly, use else if statement to specify a new condition if the first condition is false.
if (condition1) {
block of code to be executed if condition1 is true
}
else if (condition2) {
block of code to be executed if the condition1 is false and condition2 is true
}
else {
block of code to be executed if the condition1 is false and condition2 is false
}
Using two if statements means it will evaluate the first condition whether it is true, and then to execute the second if condition and untile both conditions are true, the following code can be executed.
However, the if and else if or else statement is to first evaluate the first if statement condition. When the first if condition is false, then to execute the else if or the else statement condition.