front-end developer capstone coursera week 3 quiz answers
Knowledge check: Table booking system
1. What is the purpose of the useState hook in React?
- To manage the component’s context
- To bind a value to the props of a component.
- To bind an event handler to an element.
- To manage the component’s state
2. What is missing from the code below?
import { useState } from "react";
export default function App() {
const [restaurantName, setRestaurantName] = useState();
return < h1>{restaurantName}< /h1>;
}
- An initial value for the state variable restaurantName
- The setRestaurantName function.
- The useState hook import statement
- useReducer hook was not used
3. Controlled components keep their internal state in the DOM
- True
- False
4. What is unit testing in React?
- A type of testing that ensures that a complete application is working as intended.
- A type of testing that ensures that a component’s props and state are correctly being passed down to its children.
- A type of testing that involves manually testing a component’s UI.
- A type of testing that ensures that individual units of code are working as intended.
5. What is the main difference between the useState and useReducer hooks in React?
- useState is used for managing component state, while useReducer is used for managing the component’s UI.
- useState is used for simple state updates, while useReducer is used for complex state updates.
- useState is used for managing component state, while useReducer is used for managing the component lifecycle.
- useState is used for managing component state, while useReducer is used for managing global state.
Knowledge check: Interacting with the API
6. Why should you never call hooks inside a nested function in react?
- To avoid unnecessary re-renders of the component
- To prevent memory leaks
- To ensure that the component updates correctly
- Because hooks can only be called from the top level of a function component
7. True or false. The fetch function should be used inside the componentDidMount lifecycle method or useEffect hook.
- True
- False
8. When you receive a HTTP response using the fetch() API, how do you parse the data into a JavaScript object?
- The fetch() API automatically parses the response data as a JSON object.
- You should use the JSON.parse() method to parse the response data as a JSON object.
- You should use the json() method of the response object to parse the data as a JSON object.
- You should use the text() method of the response object to parse the data as a JSON object
9. Which of the following statements are true? Choose all that apply.
- You can load local JSON files in your React project
- The fetch() API call cannot make DELETE request
- If the external API returns JSON data, you need to exclusively parse it in the fetch() API
- You cannot make multiple fetch() calls in the useEffect hook
10. Complete the sentence: JSON is ______________.
- A file format and a data exchange format
- Only a data exchange format
- Only a file format
Knowledge check: Improving the experience
11. What is a heuristics evaluation?
- A heuristics evaluation applies the brand style to a product,
- A heuristics evaluation detects accessibility problems.
- A heuristics evaluation examines and assesses the usability of a particular project.
12. Which of the following people are notable for making various product and UI design recommendations? Choose all that apply.
- Donald Knuth
- Dennis Ritchie
- Jakob Nielson
- Dieter Rams
13. There are four core principles of accessibility upon which WCAG (Web Content Accessibility Guidelines) has been built. Choose all that apply.
- Perceivable
- Understandable
- Readable
- Robust
- Operable
14. What is the term for the technical procedure where information is checked to determine if the data entered by the user is accurate?
- Double entry
- Verification
- Validation
15. In client-side validation, the form data is validated in the browser
- True
- False
Module Quiz: Project Functionality
16. Which of the following code snippets will set the initial state of a component to contain two people, one with brown hair and brown eyes and the other with blond hair and blue eyes?
- const [person, usePerson] = setState([{ hairColor: “brown”, eyeColor: “brown” },{ hairColor: “blond”, eyeColor: “blue” }]);
- const [person, setPerson] = useState([{ hairColor: “brown”, eyeColor: “brown” },{ hairColor: “blond”, eyeColor: “blue” }]);
- const [person, setPerson] = useEffect([{ hairColor: “brown”, eyeColor: “brown” },{ hairColor: “blond”, eyeColor: “blue” }]);
- const {person, setPerson} = useState([{ hairColor: “brown”, eyeColor: “brown” },{ hairColor: “blond”, eyeColor: “blue” }]);
17. Which type of destructuring is used when destructuring the useState hook?
- JSON destructuring
- Map destructuring
- Array destructuring
- Object destructuring
18. What is the type of data which is passed from a parent component to a child component?
- variable data
- state data
- mutable data
- props data
19. True or False: Form elements keep their own state in regular HTML.
- True
- False
20. Which one of the following is a common use of JSON in a React project?
- To store large amounts of data.
- To send data to a REST API.
- To display an error message to the user.
21. Which data transfer format is most commonly used with APIs?
- Text
- JSON
- XML
22. Which one of the following is a valid command for running your unit tests?
- test npm
- run test
- react test
- npm run test
23. Which type of form validation occurs after the user has pressed on the submit button?
- Ad-hoc form validation
- Client-side form validation
- Server-side form validation
24. Of the four major elements outlined by the WCAG (Web Content Accessibility Guidelines), which one is mostly concerned with providing features such as screen readers and synthesized speech?
- Operable
- Robust
- Perceivable
- Understandable
25. Which type of destructuring is being used in the following code snippet?
import React, { useState } from "react";
- import destructuring
- json destructuring
- array destructuring
- object destructuring