Mobile Development and JavaScript | Module 5
Course Name: Mobile Development and JavaScript
Course Link: Mobile Development and JavaScript
These are Mobile Development and JavaScript Week 5 Coursera Answers
Programming Assignment: Little Lemon Receipt Maker
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Module 5 Quiz: Final Graded Quiz: Programming with JavaScript
Q1. 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");
}
- Nothing
- Blue
- syntaxError
- Green
Answer: Green
Q2. What will be the output of the following JavaScript?
var message = "Hello";
message += " World!";
message = "Goodbye!";
console.log(message);
- Goodbye!
- World!
- Hello
- Hello World!
Answer: Goodbye!
Q3. What will be the output of the following JavaScript?
var x = true;
x = 23;
console.log(x);
- undefined
- true
- rangeError
- 23
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q4. What is the data type of the x variable in the following code?
var x = “Hello”;
- BigInt
- Number
- String
- Boolean
Answer: Please login to see answer.
Q5. What is the data type of the x variable in the following code?
var x = 0 != 1;
- String
- BigInt
- Number
- Boolean
Answer: Please login to see answer.
Q6. What is the data type of the x variable in the following code?
var x = 23.2;
- Boolean
- Number
- String
- BigInt
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q7. 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"); }
- undefined
- Orange
- Apple
- Pear
Answer: Please login to see answer.
Q8. 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");
}
- Pear
- Orange
- undefined
- Apple
Answer: Please login to see answer.
Q9. 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);
- 2
- 6
- 3
- 0
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q10. What will the following JavaScript code output?
var result = 0;
var i = 4;
while(i > 0) {
result += 2; i--;
}
console.log(result);
- 8
- 4
- 2
- 0
Answer: Please login to see answer.
Q11. When the following code runs, what will print out?
try { throw new Error(); console.log(‘Square’); }
catch(err) { console.log(‘Circle’); }
- Circle
- undefined
- sytaxError
- Square
Answer: Please login to see answer.
Q12. What will the following JavaScript code output?
console.log(result);
var result = 7;
- 7
- null
- undefined
- result()
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q13. What’s missing from this JavaScript function declaration?
function(a,b)
{ return a + b }
- The function name.
- The assignment operator.
- The dot notation.
- The bracket notation.
Answer: Please login to see answer.
Q14. In the following JavaScript code snippet, what is missing for the code to return the value 15?
function addTwo(a,b) { return a }
addTwo(5,10)
- Attribute
- Bracket notation
- +b in the return statement.
Answer: Please login to see answer.
Q15. What is the output of the code below?
var cat = {}
cat["sound"] = "meow";
var catSound = "purr";
console.log(cat.sound)
- catSound
- meow
- {}
- purr
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q16. What is the output of the code below?
var cat = {}
cat.sound = "meow";
var catSound = "purr"
console.log(catSound)
- {}
- purr
- catSound
- meow
Answer: Please login to see answer.
Q17. True or False: The pop method will remove the last item in an array.
- True
- False
Answer: Please login to see answer.
Q18. True or False: The second argument passed to the addEventListener function is the function that handles the event when triggered.
- False
- True
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q19. What is the first argument passed to the addEventListener function?
- A string describing the type of event (such as, ‘click’).
- A function that will handle the event.
- The name of the method.
- The target of the event.
Answer: Please login to see answer.
Q20. How do you create a new h2 element using JavaScript?
- With document.addElement(‘h2’)
- With document.createElement(‘h2’)
- With document.buildElement(‘h2’)
Answer: Please login to see answer.
Q21. What does this line of code do?
document.createElement(‘h2’).innerText = “Heading Level 2”
- It adds an inner-text HTML attribute to the h2 element.
- This syntax is invalid.
- It adds “Heading level 2” to the innerText class.
- It creates an h2 element without adding it to the page.
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q22. What does this code do?
function addFive(val) { return val + 5; };
module.exports = addFive;
- It defines the addFive function and exports it as a Node module so that it can be used in other files.
- It allows you to invoke the addFive function without the parentheses.
- This syntax is invalid.
- It allows you to invoke the addFive function without writing unnecessary code.
Answer: Please login to see answer.
Q23. What part of the following code should be changed for the code to run correctly.
const addFive = require(‘./addFive.js’)
- .js should be replaced with .node.
- addFive should be a function.
- (‘./addFive.js’) should be in brackets.
- .js is unnecessary after addFive.
Answer: Please login to see answer.
Q24. DevTools console is frequently used to perform what function?
- Testing your code.
- Installing npm.
- Downloading packages.
- Running Javascript in a web browser.
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q25. What web browser tool can you use to run Javascript?
- GUI
- console.log
- Package manager
- DevTools Console
Answer: Please login to see answer.
Q26. /* Comment */ is used to indicate which of the following information types in Javascript?
- unfinished code
- multi-line comments
- inline comments
- test code
Answer: Please login to see answer.
Q27. Which of the following comments is the correct syntax for an inline comment?
- // Comment 2
- \ Comment 1
- ## ## Comment 3 ##
- /* * Comment 4 */
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q28. Which of the following selections is not a data type?
- booleans
- numbers
- function
- string
Answer: Please login to see answer.
Q29. Which data type is used to store a true or false value?
- function
- numbers
- booleans
- string
Answer: Please login to see answer.
Q30. Which data type is used to store the value “Welcome to Javascript!”?
- numbers
- booleans
- function
- string
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q31. Which statement describes the difference between == and ===?
- == is used for numbers and === is used for strings.
- == operator compares the values as well as the data types of the operands.
- === operator compares the values as well as the data types of the operands and == symbol is used to assign variables.
- There is no difference between == and ===.
Answer: Please login to see answer.
Q32. What is unit testing?
- Unit testing gives you an efficiency rating for your code measured in units.
- Unit testing tries to imitate how a user might interact with your app.
- Unit testing revolves around the idea of having separate, small pieces of code that are easy to test.
- Unit testing is testing how parts of your system interact with other parts of our system.
Answer: Please login to see answer.
Q33. Having separate, small pieces of code that are easy to test describes what type of testing?
- Unit testing
- Integration testing
- End-to-end testing
- Post-hoc testing
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q34. True or False: End-to-end testing is the fastest and least expensive type of testing.
- False
- True.
Answer: Please login to see answer.
Q35. Which statement best describes End-to-end testing (e2e)?
- End-to-end testing revolves around the idea of having separate, small pieces of code that are easy to test.
- End-to-end testing is a comprehensive test that starts at the beginning of your code and runs to the end.
- End-to-end testing tries to imitate how a user might interact with your application.
- End-to-end testing is testing how parts of your system interact with other parts of our system.
Answer: Please login to see answer.
Q36. True or False: You can install packages from the npm repository using the node command.
- True
- False
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q37. Which statement best describes the function of package.json?
- Turn your code into an application.
- Download npm packages.
- Store all the dependencies required for application.
- Store all the testing code.
Answer: Please login to see answer.
Q38. True or False: If you build a project with multiple node packages, they will all be listed inside the package.json file.
- True
- False
Answer: Please login to see answer.
Q39. Which feature is used to mock data in Javascript?
- Jest Snapshot
- Jest Fakes
- Jest Mock functions
- External mock libraries
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q40. Which statement does not describe the process of mocking?
- You can test the front end functionality of your web app by mocking the data as if it came back from a server.
- Mocking is a substitute for testing.
- Mocks allow you to pretend that users are already there if the backend hasn’t been built yet.
- Mocking allows you to separate the code that you are testing from its related dependencies.
Answer: Please login to see answer.
Q41. True or False: End-to-end tests can be performed in a web browser without writing code.
- False
- True
Answer: Please login to see answer.
Q42. Which of the following variable declarations cannot be redeclared or reassigned?
- There are no variable declarations which cannot be reassigned.
- const
- var
- let
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q43. Which of the following variable declarations cannot be redeclared but can be reassigned?
- let
- const
- There are no variable declarations which cannot be redeclared but can be reassigned.
- var
Answer: Please login to see answer.
Q44. What will print out when the following code runs?
class Game {
constructor(score) {this.score = points; }
getPoints() { return this.score; }
}
class Bonus extends Game {
constructor() { super(2);}
getpoints() { return super.getPoints() * 5; }
}
var result = new Bonus();
console.log(result.getPoints());
- 2
- 0
- 10
- 5
Answer: Please login to see answer.
Q45. What is the function of extends in the following code block.
class Animal { }
class Cat extends Animal {
constructor() { this.noise = "meow"; }
makeNoise() { return this.noise; }
}
class Tiger extends Cat {
constructor() { super(); this.noise = "growl"; }
}
var result = new Tiger();
console.log(result.makeNoise());
- Creates a parent of the class Animal.
- Replaces the class Animal with the class Cat.
- Replaces the class Cat with the class Tiger.
- Creates a child Cat of the class Animal and a child Tiger of the class Cat.
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q46. What will print out when the following code runs?
class Animal { }
class Cat extends Animal {
constructor() { this.noise = "meow"; }
makeNoise() { return this.noise; }
}
class Tiger extends Cat {
constructor() { super(); this.noise = "growl"; }
}
var result = new Tiger();
console.log(result.makeNoise());
- syntaxError
- growl
- undefined
- meow
Answer: Please login to see answer.
Q47. console.log(…rest) will output which of the following for the below statement?
const [a, b, …rest] = [1,2,3,4]
- undefined
- 1
- [3,4]
- 2
Answer: Please login to see answer.
Q48. Which statement will log [3,4] to the console from the following code snippet?
let a, b, rest;
[a, b, …rest] = [1,2,3,4]
- console.log(…rest)
- console.log(rest)
- console.log(c+d)
- console.log(c,d)
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q49. True or false: The rest parameter syntax allows a function to accept an indefinite number of arguments as an array.
- True
- False
Answer: Please login to see answer.
Q50. What value will be printed out when the following code runs?
function count(...food)
{ console.log(food.length) }
count("Burgers", "Fries", null);
- “Burgers”, “Fries”, null
- 2
- 3
- “Burgers”, “Fries”, undefined
Answer: Please login to see answer.
Q51. JSON.parse is a static method used to do which of the following?
- Convert a JavaScript object to a JSON string.
- Convert a JSON string to a JavaScript object.
- Convert a JavaScript object to a JSON number.
- Convert a JavaScript object to a JSON boolean.
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q52. Which of the following static methods convert a JSON string into an object?
- JSON.parse
- JSON.stringify
- JSON.fromString
- JSON.toString
Answer: Please login to see answer.
Q53. A function that is called to create an instance of an object is called what?
- Constructor
- Method
- An object literal
- Argument
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q54. What keyword, used with a constructor function, details how an object will be built?
- Extends
- New
- Construct
- Function
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q55. The Object Oriented Programming paradigm can best be described how?
- It works by writing efficient code.
- It works by keeping data in meaningful objects but keeps functionality separate.
- It works by keeping the data and functionality grouped in meaningful objects.
- It works by keeping the data and functionality separate.
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q56. Which of the following concepts are not associated with the concept of functional programming?
- Higher-order function
- First-class functions
- Pure functions and side-effects
- Objects
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
Q57. The Functional Programming paradigm can best be described how?
- It works by writing efficient code.
- It works by keeping the data and functionality separate.
- It works by keeping data in meaningful objects but keeps functionality separate.
- It works by keeping the data and functionality grouped in meaningful objects.
Answer: Please login to see answer.
These are Mobile Development and JavaScript Week 5 Coursera Answers
More Weeks of this course: Click Here
More Coursera Courses: http://progiez.com/coursera
![Mobile Development and JavaScript | Module 5 1 Mobile Development and JavaScript Week 5 Coursera](https://progiez.com/wp-content/uploads/2023/01/cropped-3-progiez-logo.png-1.png)