# 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

## Final Project INTRODUCTION

In the final module, you’ll learn about the graded assessment. After you complete the individual units in this module, you’ll synthesize the skills you gained from the course to create code for the “Little lemon receipt maker”. You’ll also have to opportunity to reflect on the course content and the learning path that lies ahead.

## 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!

## FINAL GRADED QUIZ: PROGRAMMING WITH JAVASCRIPT

### 1. What will be the output of the following JavaScript?

``````const a = 2;
const b = 4;
if(a == 2 && b == 8) {
console.log("Green");
} else {
console.log("Blue");
}
``````
• Green
• Blue (CORRECT)
• Nothing

That’s correct! The AND operator requires both conditions to be true to result in a true value. Since b is equal to 4, the condition fails and the code inside the else statement will execute. Therefore, Blue will be output.

### 2. What will be the output of the following JavaScript?

``````var x = true;
x = 23;
console.log(x);
``````
• true
• 23 (CORRECT)

That’s correct! The x variable is re-assigned the value 23. Therefore, 23 is output by the code.

### 3. What is the data type of the x variable in the following code?

``````var x = 23.2;
``````
• Number (CORRECT)
• BigInt
• String
• Boolean

That’s correct. Numbers can store whole numbers such as 23 and decimal numbers such as 23.2.

### 4. What will the following JavaScript code output?

``````var x = 20;

if(x < 5) {
console.log("Apple");
} else if(x > 10 && x < 20) {
console.log("Pear");
} else {
console.log("Orange");
}
``````
• Apple
• Pear
• Orange (CORRECT)

That’s correct! All conditions will fail because x is equal to 20. Therefore, the code inside the else statement will run and output Orange.

### 5. What will the following JavaScript code output?

``````var result = 0;
for(var i = 0; i < 5; i++) {
result += 2;
}
console.log(result);
``````
• 0
• 2
• 5
• 10 (CORRECT)

That’s correct! The loop will run 5 times and each time add 2 to the result variable. Therefore, 10 will be output.

### 6. What will the following JavaScript code output?

``````var result;
console.log(result);
result = 7;
``````
• null (CORRECT)
• undefined
• 7

That’s correct! Since result is defined but unassigned, null will be output.

### 7. What will be the result of running the following JavaScript code snippet?

``````function addTwo(a,b) {
return a
}
``````
• 5 (CORRECT)
• 10
• undefined

Well done. The function is coded so that it only returns the first passed-in argument.

### 8. What is the output of the code below?

``````var car = { mileage: 200 }
var carMileage = 100
console.log(car.mileage)
``````
• 200 (CORRECT)
• 100
• 300

Well done. You can access the mileage property on the car object using the dot notation.

### 9. What is the output of the code below?

``````var veggies = []
veggies.push('parsley')
veggies.push('carrot')
console.log(veggies)``````
• undefined (CORRECT)
• 2
• 1
• 3

Well done. Trying to output the third item in the veggies array, using the syntax veggies   will console log undefined because the veggies array has only 2 items, “parsley” and “carrot”.

### 10. 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

Well done. The second argument passed to the addEventListener handles the event.

### 11. How do you create a new h2 element using JavaScript?

• With  document.createElement(‘h2’)  (CORRECT)
• With  document.buildElement(‘h2’)

Well done. You create new elements on the document object using the createElement function.

### 12. What does this code do?

``````function addFive(val) {
return val + 5;
};
``````
• It defines the addFive function and exports it as a Node module so that it can be used in other files. (CORRECT)
• This syntax is invalid.
• It allows you to invoke the addFive function without the parentheses.

Well done. It’s a way to export the addFive function as a module that can be used elsewhere.

### 13. What will be the output of the following JavaScript?

``````const a = true;
if(!a) {
console.log("Green");
} else {
console.log("Blue");
}
``````
• Green
• Blue  (CORRECT)
• Nothing

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.

### 14. 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)

That’s correct! The message variable is re-assigned as Goodbye! and output in the console.

### 15. What is the data type of the x variable in the following code?

``````var x = "Hello";
``````
• Number
• BigInt
• String (CORRECT)
• Boolean

That’s correct! Text wrapped in double quotes represents a string data type.

### 16. 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)

That’s correct! The loop will run 4 times and each time add 2 to the result variable. Therefore, 8 will be output.

### 17. What is the output of the code below?

``````var veggies = ['parsley', 'carrot']
console.log(veggies)
``````
• undefined (CORRECT)
• 2
• 1
• 3

Well done. Trying to output the third item in the veggies array, using the syntax veggies   will console log undefined because the veggies array has only 2 items, “parsley” and “carrot”.

### 18. 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.

Well done. The first argument to pass to the addEventListener function is the type of the event you’re listening for, such as “click”.

### 19. 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)

That’s correct! The loop will run 3 times and each time add 2 to the result variable. Therefore, 6 will be output.

### 20. What is the output of the code below?

``````var cat = {}
cat.sound = "meow"
var catSound = "purr"
console.log(cat.sound)
``````
• meow (CORRECT)
• purr
• {}
• catSound

Well done. Revise Module 2 Lesson 2 “CSS Basics”.

### 21. Is the code below missing a  .js  after the  ./addFive ?

``````const addFive = require('./addFive')
``````
• true
• false (CORRECT)

Well done. There’s no need to add  .js  when importing files using the  require  syntax.

### 22. 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

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.

### 23. When the following code runs, what will print out?

``````try {
throw new Error();
console.log('Square');
} catch(err) {
console.log('Circle');
}
``````
• Square
• Circle (CORRECT)

That’s correct! When the error is thrown, the catch block will execute and output Circle.

### 24. In the following following JavaScript code snippet, what is missing for the code to return the value 15?

``````function addTwo(a,b) {
return a
}
``````
• b after a in the return statement
• b after a in the return statement (CORRECT)
• Attribute

Well done. The missing code is “+ b”.

### 25. 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.

Well done. For example, to add an id attribute to an element, you can run  setAttribute(‘id’, ‘sub-heading’)

### 26. 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

Well done. Using  npm init -y  is handy way to save time setting up a new project.

### 27. 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
• Nothing

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.

### 28. What is the data type of the x variable in the following code?

``````var x = 0 != 1;
``````
• Number
• BigInt
• String
• Boolean (CORRECT)

That’s correct! 0 != 1 will result in a true value which is a boolean.

### 29. What’s missing from this JavaScript function declaration?

``````function(a,b) {
return a + b
}
``````
• The function name. (CORRECT)
• The assignment operator.
• The dot notation.

Well done. When coding function declarations, you need to give them a name.

### 30. Which of the following HTML attributes is used to handle a click event?

• Onclick (CORRECT)