Skip to content

Instantly share code, notes, and snippets.

@kylecoberly
Created October 12, 2022 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save kylecoberly/9a8a0338f410d7897a8d0b6aa1b86749 to your computer and use it in GitHub Desktop.
Save kylecoberly/9a8a0338f410d7897a8d0b6aa1b86749 to your computer and use it in GitHub Desktop.

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 called color and display it in <span></span> tags.

Write the code to import a React component named Heading using ESM syntax. Export a React component named Article that has a single prop called content. Use the Heading component in the template for the Article component, as well as a <p> tag with the content inside it.

Write the code to export a React component named RecordingIndicator that takes a boolean prop called recording. If recording 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 named UnorderedList that accepts an array called items as a prop. In the template, iterate through the items array and create a new instance of ListItem for each item, passing the item into the content prop for ListItem.

Write the code to export a React component called SignUpForm. It should have 2 labeled inputs for username and password, 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 />.

@jhardy316
Copy link

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 }; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment