This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Display(props) { | |
const list = hobbies.map((hobby) => <li>{hobby}</li>); | |
return (<div> | |
<h3>Hobbies</h3> | |
<ul>{list}</ul> | |
</div>) | |
const rows = dailyActivities.map(({time, description}, index) =>( | |
<tr key={index}> | |
<td>{time}</td> | |
<td>{description}</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
function App() { | |
const name = "Kitty Kat"; | |
const birthday = "January 1"; | |
const imageSrc = | |
"https://images.pexels.com/photos/45201/kitty-cat-kitten-pet-45201.jpeg"; | |
const hobbies = ["watching birds", "hiding in a box", "napping"]; | |
const dailyActivities = [ | |
{ time: "8:00 am", description: "wake up" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function showHelpOptions(message){ | |
let str = "" | |
for(let i=0; message.length>i; i++){ | |
if (i!== message.length -1) { | |
str += message[i] + ", "; | |
} else { | |
str += message[i] + "."; | |
} | |
} | |
return "Enter a keyword for help with a topic: " + str; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPriceInDollars(product={priceInCents: 0}) { | |
let {name, priceInCents=0, availableSizes} = product; | |
return "$" + (priceInCents / 100).toFixed(2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#grouping_objects_by_a_property |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.books = [ | |
{ | |
title: "PROLOG Programming for Artificial Intelligence", | |
authors: ["Ivan Bratko"], | |
description: | |
"Prolog has its roots in logic; however the main aim of this book is to teach Prolog as a practical programming tool.", | |
price: 89.29, | |
rating: 4.5, | |
quantity: 1, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
font-family: Helvetica; | |
font-size: 1.4em; | |
color: rgb(58, 51, 51); | |
text-align: center; | |
color: white; | |
} | |
.container div:nth-child(1), div:nth-child(6) { | |
background-color: #B8336A; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getParksByState(parks, state) { | |
let parksByState = []; | |
const parksFilter = parks.filter((parks) => { | |
if (parks.location.state === state) { | |
parksByState.push(parks); | |
} | |
}); | |
return parksByState; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkForPlagiarism (answers, textToCheck) { | |
for ( i = 0; i < answers.length; i++) { | |
let studentresponses = answers[i]; | |
if (studentresponses.response.includes(textToCheck) && studentresponses.isEssayQuestion === true) { | |
return true; | |
} | |
} | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parkByState(parks) { | |
const result = parks.reduce((acc, park) => { | |
let key = park.location.state; | |
if (!acc[key]) { | |
acc[key] = []; | |
} | |
acc[key].push(park) | |
return acc | |
}, {}); |