2.1.4.Video quiz - quanganh2001/meta-front-end-developer-professional-certificate-coursera GitHub Wiki
Welcome to Programming
Introduction to programming
The zeros and ones of binary code is a low-level language because it's closer to being understood by a CPU. JavaScript on the other hand is a high-level language. This means that it has to be converted to binary code so that a CPU can work with it.
A. Yes
B. No
Explain: As a high-level language, JavaScript does need to be converted to binary code so that a CPU can work with it.
Why Javascript?
You are building a website using JavaScript. On which end of the site will JavaScript add interactivity to?
A. Back-end
B. Front-end
Explain: JavaScript adds interactivity to the front-end, or client-side, of a webpage.
Programming in Javascript
JavaScript is integral to our everyday online experiences. Which of the following statements are true? Choose all that apply.
- Javascript can provide a native feel to apps
- Using Javascript and React Native developers can create mobile apps
- JavaScript is used to power websites.
- JavaScript can't communicate with databases.
Explain: Using JavaScript developers can create an original user experience. JavaScript isn't limited to only being used in browsers. Developers can also create apps using it in conjunction with React Native. JavaScript is after all often called the language of the web.
Variables
In JavaScript you can declare a variable with the keyword var. Which one of the following statements about var is correct?
A. You use var to change the value of a variable.
B. Var allows you to assign a value to a variable.
C. Var allows you to save a variable so that you can re-use it in future.
The correct answer is C. Explain: Var makes your life as a programmer easier by allowing you to re-use a variable multiple times.
Data types
Which of the following are examples of valid strings? Choose all that apply.
- Hello world
- "Hello world"
- 'Hello world'
Explain: Strings must be enclosed in either single or double quotations.
Operators
Which of the following are examples of logical operators? Check all that apply.
- Substraction
- And
- Multiplication
- Or
- Not
Explain: And, Or and Not are logical operators, not a math operator.
Numbers
If parentheses are not used in a mathematical calculation JavaScript will ...
A. Add all variables first.
B. Follow the standard mathematical sequence of calculation.
C. Follow the sequence the calculation is in from left to right.
The correct answer is B. Explain: If parentheses are not used in a mathematical calculation, JavaScript will follow the standard mathematical sequence of calculation.
Strings
String literals are used to create string values in Javascript. Which of the following are string literals? Select all that apply.
- Double quotation marks
- Single quotation marks
- Backticks
Explain: You can use single or double quotation marks to make a string literal.
Booleans
There are various uses of the Boolean data type, one of which is to compare various values and types and it is used in conjunction with various operators such as the strict equality operator. True or false: the strict equality operator only checks for value and not type as well.
A. True
B. False
It is false statement. Explain: The strict equality operator which is three equal signs is used to check for value and type.
Conditional and Loops
Writing statements
True or false: An if statement can be used to run code based on a condition being true.
A. True
B. False
Explain: Yes, an if statement can be used to run code based on a condition being met.
Working with conditional statements
You need to execute code based on a certain condition being either true or false. Which of the following types of statements can you use to complete this task? Select all that apply.
- A switch statement
- A for loop
- A conditional statement
Explain: A conditional statement can be used to execute code based on a certain condition being either true or false.
Looping constructs
You need to execute repeated blocks of JavaScript code until a certain condition is satisfied. Can you perform this action using loops?
A. Yes
B. No
Explain: Yes, JavaScript developers use loops to continually execute repeated blocks of code until a certain condition is satisfied.
For loop
How many lines will the loop below print in the console?
for (var i = 0; i <= 3; i++) {
console.log("This is line ", i)
}
A. 0
B. 1
C. 2
D. 3
E. 4
The correct answer is 4. Explain: The loop iterates 4 times, from zero to 3.
While loop
True or false: A while loop will keep looping through a code block as long as a specified condition is true?
A. True
B. False
It is true statement. Explain: A while loop will keep looping through a code block as long as a specified condition is true.
Nested loops
You are running multiple nested loops within your JavaScript code. Could these nested loops cause performance issues with your code?
A. Yes
B. No
Explain: The more nested loops there are, the slower your code will run.