react basics coursera week 3 quiz answers
Knowledge check: Navigation
1. Is the following description true or false? A Single Page Application allows the user to interact with the website without downloading entire new webpages. Instead, it rewrites the current webpage as the user interacts with it. The outcome is that the application will feel faster and more responsive to the user.
- True
- False
2. How do React components turn into the webpage that you see?
- In simple terms, a React component gets downloaded from the server every time a user interacts with a React app.
- In simple terms, a React component has a one-to-one relationship to a HTML element that is displayed on the webpage and React keeps track of which HTML elements need to be updated.
- In simple terms, React downloads a VDOM instance from the server to render all its pages.
3. A SPA can’t have regular anchor tag elements like a traditional web app can. The reason for this is that an anchor tag will load another html file from a server and refresh the page.
- True
- False
4. A total page refresh is not the way that a SPA works.
- True
- False
5. Complete the sentence: an SPA comes with its own special implementation of anchor tags and links, which only give an illusion of loading different pages to the end user, when in fact they simply...
- load different components into a single element of the real DOM into which the virtual DOM tree gets mounted and updated
- load different components into a single element of the virtual DOM into which the real DOM tree gets mounted and updated
- load a single component into multiple elements of the real DOM into which the virtual DOM tree gets mounted and updated
Knowledge check: Conditional updates
6. Select all the conditional structures that exist in JavaScript. Select all that apply.
- ternary operator
- switch statement
- if-else statement
- logical && operator
7. What will be the output if you ran this code in the browser console:
true && 5
- true
- false
- undefined
- 5
8. If the value of the test variable evaluates to true, what will the following code render?
< div > {
test && < h1 > Hello < /h1>} World < /div>
- World
- Hello
- An empty div
- Hello World
9. If the value of morning is false, what will the following code render?
{
morning ? < h2 > Breakfast time! < /h2> : < h2>Lunch time!< /h2 >
}
- Lunch time!
- Breakfast time!
10. Choose the correct syntax to build a new Date object in JavaScript?
- new Date;
- New Date();
- new Date();
- Date();
Module quiz: navigation, updating and assets in React.js
11. True or false? In React, you can use a ternary operator in a component's return statement in React.
- True
- False
12. React Router is...
- A stand-alone package that you can add to a React app.
- A built-in part of React.
- A built-in part of React-DOM.
13. React Router has a element.
- True
- False
14. Please choose the valid command to install react-player.
- npm install react-player
- npm-install react-player
- npm-install-react-player
15. True or false? webpack is a module bundler.
- True
- False
16. What will be the output of the code below?
let name; if (Math.random() > 0.5) { name = "Mike"} else { name = "Susan"}
- It will always be Susan
- It will be 0.5
- It will be sometimes Mike, and sometimes Susan, randomly
- It will always be Mike
17. Is the following component syntactically correct?
import car from "./assets/images/car.jpg";
function CarImage() {
return (
< img
height={200}
src={car}
alt="Car image"
/ >
);
};
export default CarImage;
- Yes
- No
18. What is an asset?
- Images, stylesheets, fonts
- Components
- Images, video, and components
19. What is the syntax used to add a new dev dependency to a React app? Select all that apply.
- node init some-package-name
- npm init some-package-name
- npm install –save-dev some-package-name
- npm i –save-dev some-package-name
20. If your app can compile without it, you can keep an asset in a public folder.
- True
- False