Using JavaScript, write a function that accepts a string and logs it.
Add the JavaScript code that iterates through each of these words using a
for
loop and concatenates them into a sentence. Don't forget to add spaces!
const words = ["The", "quick", "brown", "fox"]
let sentence = ""
// Your code here
console.log(words)
Using
.filter()
and.forEach()
, add the necessary JavaScript to print out only the 2 even numbers, such as:
2
4
const numbers = [{
content: 1,
},{
content: 2,
},{
content: 3,
},{
content: 4,
},{
content: 5,
}]
Describe React components as best you can.
Write the code to create a component named
GoodbyeHome
. It should have the template<h1>Goodbye, home!</h1>
!
Write the code to create a component named
ShowColor
. It should accept a prop calledcolor
and display it in<span></span>
tags.
Write the code to import a React component named
Heading
using ESM syntax. Export a React component namedArticle
that has a single prop calledcontent
. Use theHeading
component in the template for theArticle
component, as well as a<p>
tag with thecontent
inside it.
Write the code to export a React component named
RecordingIndicator
that takes a boolean prop calledrecording
. Ifrecording
is true, the component should display<span>Recording!</span>
, otherwise it should display nothing.
Write the code to import a React component named
ListItem
using ESM syntax. Export a React component namedUnorderedList
that accepts an array calleditems
as a prop. In the template, iterate through theitems
array and create a new instance ofListItem
for each item, passing the item into thecontent
prop forListItem
.
Write the code to export a React component called
SignUpForm
. It should have 2 labeled inputs forusername
andpassword
, both of which should be logged to the console when the form is submitted.
Using the API endpoint https://pokeapi.co/api/v2/pokemon/bulbasaur, write the code to create a component that fetches a Bulbasaur object and displays a sprite (eg.
bulbasaur.sprites.front_default
) in an<img />
.
function (inputString: string) {
console.log( {inputString} );
}
2.
const words = ["The", "quick", "brown", "fox"]
let sentence = ""
for each (word in words) {
sentence +== word + “ “;
}
console.log(sentence);
const evenNumbers = numbers.filter(
content === 2 || content === 4 );
evenNumbers.forEach(
console.log( content )
);
React components are tools available in the React platform that allow developers to access features and functions that would be more difficult in straight Javascript.
5.
function GoodbyeHome () [
Goodbye, home!
] 6. function ShowColor ( color ) { { color }; }