
Course 2 – Programming with JavaScript quiz answers
Week 5: End-of-Course Assessment
Meta Front-End Developer Professional Certificate
Complete Coursera Answers & Study Guide
Click to Enroll in Coursera Meta Front-End Professional Certificate
End-of-Course Assessment INTRODUCTION
This final module of the Meta Front-End Developer Professional Certificate from Coursera is designed to test and evaluate your mastery of the skills gained throughout the course. You will be tasked with creating code for the “Little Lemon Receipt Maker” using all that you have learned. After completion, you can take a graded End-of-Course Assessment to demonstrate your expertise in front-end development as part of this certificate.
Moreover, at the end of this module, you will also have an opportunity to reflect on what you have learned and where your journey should go next. The End-of-Course Assessment is just one step towards validating your knowledge in front-end development, but it will give you valuable insight into how far your skill set has advanced. Use this to your advantage as you continue your studies and progress towards mastering front-end development.
Learning Objectives
- Revise conditional statements, for loops, looping over arrays of objects, comparison operators, booleans, strings, numbers, arithmetic operators.
SELF REVIEW: LITTLE LEMON RECEIPT MAKER
1. Were you able to code the conditional statements for the value of the passed-in argument to the invoked getPrices() function?
- Yes (Correct)
- No
Correct
2. Did you assign the finalPrice variable conditionally (in one condition, multiplied by the tax, and in the other condition, with no tax multiplied)?
- Yes (Correct)
- No
Correct
3. Is your loop outputting all the objects’ data from the dishData array?
- Yes (Correct)
- No
Correct
END-OF-COURSE GRADED ASSESSMENT
1. What will be the output of the following JavaScript?
const a = 10;
const b = 5;
if(a == 7 || b == 5) {
console.log("Green");
} else {
console.log("Blue");
}
- Green (Correct)
- Blue
Correct: That’s correct. The logical OR operator results in the condition being true. Therefore, the code inside the if statement will execute and Green will be output.
2. What will be the output of the following JavaScript?
var message = "Hello";
message += " World!";
message = "Goodbye!";
console.log(message);
- Hello
- World!
- Hello World!
- Goodbye! (Correct)
Correct: That’s correct! The message variable is re-assigned as Goodbye! and output in the console.
3.1. What is the data type of the x variable in the following code?
var x = 0 != 1;
- Number
- BigInt
- String (Correct)
- Boolean
Correct
3.2. What is the data type of the x variable in the following code?
var x = "Hello";
- Number
- BigInt
- String (Correct)
- Boolean
4.1. What will the following JavaScript code output?
var x = 10;
if(x > 10) {
console.log("Apple");
} else if(x > 5) {
console.log("Pear");
} else {
console.log("Orange");
}
- Apple
- Pear (Correct)
- Orange
Correct: That’s correct. The x variable is equal to 10 so the first condition fails but the second condition succeeds. Therefore, the code inside the else if statement executes and Pear is output.
4.2. What will the following JavaScript code output?
var x = 20;
if(x >= 10) {
console.log("Apple");
} else if(x <= 5) {
console.log("Pear");
} else {
console.log("Orange");
}
- Apple (Correct)
- Pear
- Orange
5.1. What will the following JavaScript code output?
var result = 0;
var i = 4;
while(i > 0) {
result += 2;
i--;
}
console.log(result);
- 0
- 2
- 4
- 8 (Correct)
Correct: That’s correct! The loop will run 4 times and each time add 2 to the result variable. Therefore, 8 will be output.
5.2 What will the following JavaScript code output?
var result = 0;
var i = 0;
var limit = 3;
while(i < limit) {
result += 2;
i++;
}
console.log(result);
- 0
- 2
- 3
- 6 (Correct)
Correct: That’s correct! The loop will run 3 times and each time add 2 to the result variable. Therefore, 6 will be output.
6.1. What will the following JavaScript code output?
var result;
console.log(result);
result = 7;
- null (Correct)
- undefined
- 7
Correct: Yes, unit testing involves the process of testing the smallest units of your source code in isolation.
7. What will the following JavaScript code output?
console.log(result);
var result = 7;
- Null
- Undefined (Correct)
- 7
8. What’s missing from this JavaScript function declaration?
function(a,b) {
return a + b
}
- The function name. (Correct)
- The assignment operator.
- The dot notation.
9.1. What is the output of the code below?
var cat = {}
cat.sound = "meow"
var catSound = "purr"
console.log(cat.sound)
- meow (Correct)
- purr
- {}
- catSound
Correct: Well done. Revise Module 2 Lesson 2 “CSS Basics”.
9.2. What is the output of the code below?
var cat = {}
cat["sound"] = "meow"
var catSound = "purr"
console.log(cat.sound)
- meow (Correct)
- purr
- {}
- catSound
Correct: Well done. Console logging the sound property on the cat object will output the string “meow”.
10.1. What is the output of the code below?
var veggies = ['parsley', 'carrot']
console.log(veggies[2])
- undefined (Correct)
- 2
- 1
- 3
Correct: Well done. Trying to output the third item in the veggies array, using the syntax veggies [2] will console log undefined because the veggies array has only 2 items, “parsley” and “carrot”.
10.2. What is the output of the code below?
var veggies = []
veggies.push('parsley')
veggies.push('carrot')
console.log(veggies[2])
- undefined (Correct)
- 2
- 1
- 3
11. True or False. The second argument passed to the addEventListener function is the actual function that will handle the event, when it gets triggered.
- True (Correct)
- False
Correct: Well done. The second argument passed to the addEventListener handles the event.
12. How can you add an HTML attribute to an HTML element using JavaScript?
- By invoking the setAttribute method on a given element. (Correct)
- By invoking the getAttribute method on a given element.
- By invoking the createAttribute method on a given element.
13. True or false? Using the npm init -y command you can initialize a new project with npm with all the prompts answered with a ‘yes’.
- True (Correct)
- False
Correct: Well done. Using npm init -y is handy way to save time setting up a new project.
14. What is the output of the code below?
var car = { mileage: 200 }
var carMileage = 100
console.log(car.mileage)
- 200 (Correct)
- 100
- 300
Correct: Well done. You can access the mileage property on the car object using the dot notation.
15. Which of the following HTML attributes is used to handle a click event?
- Onclick (Correct)
- addEventListener(‘click’)
- ‘click’
Correct: Well done. The onlick HTML attribute is used to handle click events.
16. What does this line of code do?
- document.createElement(‘h2’).innerText = “Heading Level 2”
- It creates an h2 element without adding it to the page. (Correct)
- This syntax is invalid.
- It adds an inner-text HTML attribute to the h2 element.
Correct: That’s correct! End-to-end tests can be performed in a web browser without writing code. This is because the tests mimic how a user will interact with the application.
17. What will be the output of the following JavaScript?
var x = 2;
x += 5;
console.log(x);
- 2
- 3
- 5
- 7 (Correct)
Correct: That’s correct! The x variable is initially assigned the value 2. Then 5 is added to the variable and the result is stored in the variable. Therefore, 7 is output by the code.
18. What will be the result of running the following JavaScript code snippet?
function addTwo(a,b) {
return a
}
addTwo(5,10)
- 5 (Correct)
- 10
- Undefined
Correct: Well done. The function is coded so that it only returns the first passed-in argument.
19. What is the first argument passed to the addEventListener function?
- A string describing the type of event (such as, “click”). (Correct)
- A function that will handle the event.
- The target of the event.
Correct: That’s correct! The x variable is initially assigned the value 2. Then 5 is added to the variable and the result is stored in the variable. Therefore, 7 is output by the code.
20. Is the code below missing a .js after the ./addFive ?
const addFive = require('./addFive')
- false (Correct)
- true
Correct: Well done. There’s no need to add .js when importing files using the require syntax.
21. When the following code runs, what will print out?
try {
throw new Error();
console.log('Square');
} catch(err) {
console.log('Circle');
}
- Square
- Circle (Correct)
Correct: That’s correct! When the error is thrown, the catch block will execute and output Circle.
22. True or False. You use the pop method on an array to remove the last item from it.
- True (Correct)
- False
Correct: Well done. The pop method removes the last item from an array.
23. How do you create a new h2 element using JavaScript?
- With document.createElement(‘h2’) (Correct)
- With document.buildElement(‘h2’)
- With document.addElement(‘h2’)
Correct: Well done. You create new elements on the document object using the createElement function.
24. What will be the output of the following JavaScript?
const a = true;
if(!a) {
console.log("Green");
} else {
console.log("Blue");
}
- Green
- Blue (Correct)
Correct: That’s correct! The NOT operator results in the condition being false. Therefore, the code inside the else statement will execute and Blue will be output.
End-of-Course Assessment CONCLUSION
In the final module of this course, you’ll synthesize the skills you gained throughout the units to create code for the “Little lemon receipt maker.” After you complete the individual units in this module, you will be able to take the graded assessment.
You’ll also have an opportunity to reflect on the course content and think about what lies ahead in your learning journey. Don’t wait any longer. Join Coursera now!
Subscribe to our site
Get new content delivered directly to your inbox.
Quiztudy Top Courses
Popular in Coursera
- 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!