COURSE 8: MOBILE DEVELOPMENT AND JAVASCRIPT QUIZ ANSWERS
Week 1: Introduction to JavaScript
Meta Android/IOS Developer Professional Certificate
Complete Coursera Answers & Study Guide
Enroll in Coursera Meta IOS Developer Professional Certification
Enroll in Coursera Meta Android Developer Professional Certification
TABLE OF CONTENT
- SELF REVIEW: DECLARING VARIABLES
- SELF REVIEW: ADVANCED USE OF OPERATORS
- KNOWLEDGE CHECK: WELCOME TO PROGRAMMING
- SELF REVIEW: PRACTICE CONDITIONAL STATEMENTS
- SELF REVIEW: REPETITIVE TASKS WITH LOOPS
- SELF REVIEW: WORKING WITH CONDITIONALS AND LOOPS
- KNOWLEDGE CHECK – CONDITIONALS AND LOOPS
- MODULE QUIZ: INTRODUCTION TO JAVASCRIPT
Introduction to JavaScript INTRODUCTION
In this module, you are introduced to JavaScript. You’ll learn why JavaScript is so integral to software development. And you’ll get an overview of how to write JavaScript code inside the browser. Furthermore, you will learn about the most common operators as well as conditional statements and loops.
Learning Objectives
- Explain the importance of JavaScript in software development
- Demonstrate how to write JavaScript code inside the browser
- Demonstrate how to write basic JavaScript code: List common operators, conditional statements and loops
- Demonstrate how to use variables and output their values in the console
SELF REVIEW: DECLARING VARIABLES
1. Did you complete the Declaring variables exercise?
- Yes (CORRECT)
- No
Well done on completing the exercise! While this was repetitive, it does help to engrain the activity of declaring variables and checking their values. It’s something that you will do every day as a developer.
2. Are you comfortable with using console.log?
- Yes (CORRECT)
- No
Excellent! It’s important to get used to using console.log, as this is one of the most common commands you will use in JavaScript.
3. Are you comfortable using the assignment operator?
- Yes (CORRECT)
- No
Great! Understanding that the = operator is the assignment operator in JavaScript, is a very important concept to have a handle on.
4. 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.
- Yes (CORRECT)
- No
Yes, that’s correct! As a high-level language, JavaScript does need to be converted to binary code so that a CPU can work with it.
5. You are building a website using JavaScript. On which end of the site will JavaScript add interactivity to?
- Front-end (CORRECT)
- Back-end
Yes, JavaScript adds interactivity to the front-end, or client-side, of a webpage.
6. JavaScript is integral to our everyday online experiences. Which of the following statements are true? Choose all that apply.
- JavaScript can’t communicate with databases.
- Using JavaScript and React Native developers can create mobile apps. (CORRECT)
- JavaScript can provide a native feel to apps. (CORRECT)
- JavaScript is used to power websites. (CORRECT)
That’s correct! JavaScript isn’t limited to only being used in browsers. Developers can also create apps using it in conjunction with React Native.
That’s correct! Using JavaScript developers can create an original user experience.
That’s correct! JavaScript is after all often called the language of the web.
7. In JavaScript you can declare a variable with the keyword var. Which one of the following statements about var is correct?
- Var allows you to assign a value to a variable.
- You use var to change the value of a variable.
- Var allows you to save a variable so that you can re-use it in future. (CORRECT)
Yes, that’s correct! Var makes your life as a programmer easier by allowing you to re-use a variable multiple times.
SELF REVIEW: ADVANCED USE OF OPERATORS
1. Did you complete the Advanced use of operators exercise?
- Yes (CORRECT)
- No
Well done on completing the exercise!
2. Did you find any part of the exercise on the Advanced Use of Operators difficult?
- Yes
- No
- Yes
- No (CORRECT)
Thank you for completing the Advanced Use of Operators exercise.
3. Would you say that you are able to explain, in your own words, how logical operators &&, ||, and ! work in JavaScript?
- Yes (CORRECT)
- No
Great! Being able to describe newly-learned concepts in your own words is a reflection of a better understanding of the subject matter.
4. Which of the following are examples of valid strings? Choose all that apply.
- “Hello world” (CORRECT)
- ‘Hello world’ (CORRECT)
- Hello world
Correct. Strings must be enclosed in either single or double quotations.
Correct. Strings must be enclosed in either single or double quotations.
5. Which of the following are examples of logical operators? Check all that apply.
- And (CORRECT)
- Not (CORRECT)
- Or (CORRECT)
- Multiplication
- Subtraction
That’s correct! And is a logical operator, not a math operator.
That’s correct! Not is a logical operator, not a math operator.
That’s correct! Or is a logical operator, not a math operator.
6. If parentheses are not used in a mathematical calculation JavaScript will …
- Follow the sequence the calculation is in from left to right.
- Add all variables first.
- Follow the standard mathematical sequence of calculation. (CORRECT)
That’s right! If parentheses are not used in a mathematical calculation, JavaScript will follow the standard mathematical sequence of calculation.
7. String literals are used to create string values in JavaScript. Which of the following are string literals? Select all that apply.
- Backticks
- Single quotation marks (CORRECT)
- Double quotation marks (CORRECT)
Correct! You can use single or double quotation marks to make a string literal.
Correct! You can use single or double quotation marks to make a string literal.
8. 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.
- True
- False (CORRECT)
That’s correct! The strict equality operator which is three equal signs is used to check for value and type.
KNOWLEDGE CHECK: WELCOME TO PROGRAMMING
1. What is the data type of the value “Hello, World”?
- string (CORRECT)
- number
- boolean
That’s correct! The value of “Hello, World” is of the string data type.
2. What is the data type of the value true ?
- string
- number
- boolean (CORRECT)
That’s correct! The values of true and `false are of the boolean data type.
3. What is the % operator?
- The modulus operator (CORRECT)
- The division operator
- The concatenation operator
That’s correct! The modulus operator is represented using the % symbol.
4. What happens when you use the + operator on two strings?
- They get joined into a single string (CORRECT)
- It shows error
- You can’t use the + operator on two strings
- It creates a string array
That’s correct! Using the + operator on two strings joins the strings together.
5. What is the operator symbol && represent in JavaScript?
- The logical OR operator
- The logical AND operator (CORRECT)
- The logical NOT operator
That’s correct! In JavaScript, the && is the logical AND operator.
6. What happens when you use the + operator on a string and a number?
- Nothing – you can’t use the + operator on different data types
- They get joined together as if both of them were strings (CORRECT)
- It shows error
That’s correct! Using the + operator on a string and a number joins them together as if both of them were strings.
7. What is the value of i after the following code runs?
var i = 7; i += 1; i += 2;
- 7
- 8
- 9
- 10 (CORRECT)
That’s correct. 1 is added to i and the result is stored in i . The value is now 8. Then, 2 is added to i and the result is stored in i . The value is now 10 .
SELF REVIEW: PRACTICE CONDITIONAL STATEMENTS
1. Did you complete the Practice conditional statements exercise?
- Yes (CORRECT)
- No
Well done on completing the exercise!
2. Were there any parts of the Practice conditional statements exercise that you found difficult to complete?
- Yes
- No (CORRECT)
Thank you for completing the Practice conditional statements exercise.
3. Would you say that you are able to explain, in your own words, how an if statement and a switch statement work in JavaScript?
- Yes (CORRECT)
- No
Great! Being able to describe newly-learned concepts in your own words is a reflection of a better understanding of the subject matter.
4. True or false: An if statement can be used to run code based on a condition being true.
- True (CORRECT)
- False
Yes, an if statement can be used to run code based on a condition being met.
5. 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 for loop
- A switch statement (CORRECT)
- A conditional statement (CORRECT)
Correct! A switch statement can be used to execute code based on a certain condition being either true or false.
Correct! A conditional statement can be used to execute code based on a certain condition being either true or false.
SELF REVIEW: REPETITIVE TASKS WITH LOOPS
1. Did you complete the Repetitive tasks with loops exercise?
- Yes (CORRECT)
- No
Well done on completing the exercise!
2. Were there any parts of the Repetitive tasks with loops exercise that you found difficult to complete?
- Yes
- No (CORRECT)
Thank you for completing the Repetitive tasks with loops exercise.
3. Would you say that you are able to explain, in your own words, what does the i++ do?
- Yes (CORRECT)
- No
Great! Being able to describe newly-learned concepts in your own words is a reflection of a better understanding of the subject matter.
4. Are you able to explain, in your own words, the syntax of a for loop in JavaScript?
- Yes (CORRECT)
- No
Great! Being able to describe newly-learned concepts in your own words is a reflection of a better understanding of the subject matter.
5. You need to execute repeated blocks of JavaScript code until a certain condition is satisfied. Can you perform this action using loops?
- Yes (CORRECT)
- No
Yes, JavaScript developers use loops to continually execute repeated blocks of code until a certain condition is satisfied.
6. How many lines will the loop below print in the console?
for (var i = 0; i <= 3; i++) {
console.log("This is line ", i)
}
- 0
- 1
- 2
- 3
- 4 (CORRECT)
That is correct. The loop iterates 4 times, from zero to 3.
7. True or false: A while loop will keep looping through a code block as long as a specified condition is true?
- True (CORRECT)
- False
Correct. A while loop will keep looping through a code block as long as a specified condition is true.
SELF REVIEW: WORKING WITH CONDITIONALS AND LOOPS
1. Did you complete the Working with conditionals and loops exercise?
- Yes (CORRECT)
- No
Well done on completing the exercise!
2. Were there any parts of the Working with conditionals and loops exercise that you found difficult to complete?
- Yes
- No (CORRECT)
Thank you for completing the Working with conditionals and loops exercise.
3. Would you say that you are able to explain, in your own words, how to code for loops and switch statements in JavaScript?
- Yes (CORRECT)
- No
Great! Being able to describe newly-learned concepts in your own words is a reflection of a better understanding of the subject matter.
4. You are running multiple nested loops within your JavaScript code. Could these nested loops cause performance issues with your code?
- Yes (CORRECT)
- No
Correct. The more nested loops there are, the slower your code will run.
KNOWLEDGE CHECK – CONDITIONALS AND LOOPS
1. Based on the following code, what will print out when the variable i has the value 3 ?
if(i < 5) {
console.log("Hello");
} else {
console.log("Goodbye");
}
- Hello (CORRECT)
- Goodbye
That’s correct! The code inside the if statement will execute because the condition i < 5 is true.
2. Based on the following code, what will print out when the variable i has the value 1 ?
if(i == 0 && i == 1) {
console.log("Hello");
} else {
console.log("Goodbye");
}
- Hello
- Goodbye (CORRECT)
That’s correct! The condition checks if i is equal to 0 AND 1 . Since it is not possible for i to be both values at the same time, the result of this check is false. Therefore, the code inside the else statement will run.
3. How many times will the following code print the word ‘Hello’?
for (i = 0; i < 2; i++) {
console.log("Hello");
}
- 1
- 2 (CORRECT)
- 3
- 4
That’s correct! The loop will run twice based on the condition i < 2 .
4. How many times will the following code print the word ‘Hello’?
var i = 0;
while(i < 3) {
console.log("Hello");
i++;
}
- 1
- 2
- 3 (CORRECT)
- 4
That’s correct! The loop will run 3 times based on the condition i < 3 .
5. How many times will the following code print the word ‘Hello’?
for (i = 0; i < 2; i++) {
for (var j = 0; j < 3; j++) {
console.log("Hello");
}
}
- 2
- 3
- 4
- 6 (CORRECT)
That’s correct! The inner loop will be run twice by the outer loop. Since the inner loop runs 3 times, the console.log will be called 6 times in total.
6. Based on the following code, what will print out when the variable i has the value 7 ?
if(i <= 5) {
console.log("Hello");
} else if(i <= 10) {
console.log("Goodnight");
} else {
console.log("Goodbye");
}
- Hello
- Goodnight (CORRECT)
- Goodbye
That’s correct! The code inside the else if statement will execute. The first condition fails because the value of i is greater than 5. The second condition succeeds because the value of i is less than 10.
7. Based on the following code, what will print out when the variable i has the value 3 ?
switch(i) {
case 1:
console.log("Hello");
break;
case 2:
console.log("Goodnight");
break;
case 3:
console.log("Goodbye");
break;
}
- Hello
- Goodnight
- Goodbye (CORRECT)
That’s correct! The code for case 3 will run.
8. Based on the following code, what will print out when the variable i has the value 3 ?
if(i == 2 || i == 3) {
console.log("Hello");
} else {
console.log("Goodbye");
}
- Hello (CORRECT)
- Goodbye
That’s correct! The condition checks if i is equal to 2 OR 3 . Since the value of i is 3 , the code inside the if statement will run.
MODULE QUIZ: INTRODUCTION TO JAVASCRIPT
1. You can run JavaScript in a web browser’s devtools console.
- true (CORRECT)
- false
That’s correct! The devtools console is useful for running JavaScript code.
2. Which of the following are valid comments in JavaScript? Select all that apply.
\ Comment 1
// Comment 2
(CORRECT)## Comment 3
/*
Comment 4
*/
(CORRECT)
That’s correct! // is used for inline comments.
That’s correct! /* and */ are define the beginning and end of multi-line comments.
3. Which of the following are valid data types in JavaScript? Select all that apply.
- string (CORRECT)
- numbers (CORRECT)
- booleans (CORRECT)
- null (CORRECT)
That’s correct! The string data type represents a sequence of characters in JavaScript.
That’s correct! Numbers represent both integer and decimal point numeric values.
That’s correct! The boolean data type has one of two values; true or false.
That’s correct! The null data type represents the absense of a value.
4. Which of the following is the logical AND operator in JavaScript?
- &
- && (CORRECT)
- ||
- |\
That’s correct! && is the logical AND operator used for condition checks.
5. Which of the following is the assignment operator in JavaScript?
- = (CORRECT)
- ==
- ===
That’s correct! The = symbol is used to assign to variables in JavaScript.
6. How many times will the following code print the word ‘Hello’?
for(var i = 0; i <= 5; i++) {
console.log("Hello");
}
- 4
- 5
- 6 (CORRECT)
That’s correct! ‘i’ starts with the value ‘0’. The condition checks if ‘i’ is less than or equal to ‘5’. Each loop increments ‘i’ by ‘1’. This means that the loop will run 6 times.
7. What will print out when the following code runs?
var i = 3;
var j = 5;
if(i == 3 && j < 5) {
console.log("Hello");
} else {
console.log("Goodbye");
}
- Hello
- Goodbye (CORRECT)
- Nothing
That’s correct! The condition checks if ‘i’ is equal to ‘3’ AND if ‘j’ is less than ‘5’. Since the result of this condition is false, the code inside the else statement will run.
8. What will print out when the following code runs?
var i = 7;
var j = 2;
if(i < 7 || j < 5) {
console.log("Hello");
} else {
console.log("Goodbye");
}
- Hello (CORRECT)
- Goodbye
- Nothing
That’s correct! The condition checks if ‘i’ is less than ‘7’ OR if ‘j’ is less than ‘5’. Since the result of this condition is true, the code inside the if statement will run.
9. The result of !false is:
- true (CORRECT)
- undefined
Correct! When you add the NOT operator before a boolean value, the returned value is the opposite of the boolean value. Thus, !false is evaluated to true, and !true is evaluated to false.
10. What does the operator symbol || represent in JavaScript?
- The logical NOT operator
- The logical OR operator (CORRECT)
- The logical AND operator
That’s correct. In JavaScript, the || is the logical OR operator.
Introduction to JavaScript CONCLUSION
TBW
This Course is Shared with IOS and Android developer Certification, Choose which way to go
Subscribe to our site
Get new content delivered directly to your inbox.
Quiztudy Top Courses
Popular in Coursera
- Google Advanced Data Analytics
- Google Cybersecurity Professional Certificate
- Meta Marketing Analytics Professional Certificate
- Google Digital Marketing & E-commerce Professional Certificate
- Google UX Design Professional Certificate
- Meta Social Media Marketing Professional Certificate
- Google Project Management Professional Certificate
- Meta Front-End Developer Professional Certificate
Liking our content? Then, don’t forget to ad us to your BOOKMARKS so you can find us easily!