I think the point of this exercise was to show the string interpolation use like when you have something like this:
var cat =‘meow’
var string = The cat says ${cat};
I think they are showing that usage but with this/JSX/React stuff… Though I will say step two which was write a new name to pass the exercise felt like busy work and not really pushing the concept further. This unit overall might need a bit of a tweak.
The backticks don’t show because they are used in Markdown to denote inline code blocks, similar to using <code></code> tags in HTML.
In order to render the backticks they must be preceded by a backslash ( \ ). So in your example it could be written as so:
var string = The cat says `${cat}`;
An alternative is to use three backticks ( ``` ) before and after code to denote a code block:
var cat = 'meow';
var string = The cat says `${cat}`
Hope this helps clear it up a bit. Markdown can be very useful to easily add some basic formatting like lists, headings, quotes etc. I use it for taking notes as it allows me to format all my information like it is one large HTML document, without the cumbersome opening and closing tags.
in the following code, the define the first name (Groberta), after declaring the new react component which involves the first name. why isn’t there an error? why does this work? Is it because of hoisting?
import React from ‘react’;
import ReactDOM from ‘react-dom’;
class Greeting extends React.Component {
render() {
return
That is, to inject tag values into the Product() function, which is located in the Product.js file, I have to switch and watch another App.js file? Because it is in the App.js we create attributes and assign values to <Product />.
And if there are 20 attributes? It’s not really convenient.
Can I somehow write <Product /> attributes in a file Product.js ?