Skip to content

Instantly share code, notes, and snippets.

View stoneboyindc's full-sized avatar

Nick Chang stoneboyindc

View GitHub Profile
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>
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" },
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;
function getPriceInDollars(product={priceInCents: 0}) {
let {name, priceInCents=0, availableSizes} = product;
return "$" + (priceInCents / 100).toFixed(2);
}
@stoneboyindc
stoneboyindc / reduce()
Created March 1, 2021 23:07
how to use reduce() to group object by a property
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#grouping_objects_by_a_property
@stoneboyindc
stoneboyindc / sortByPrice()
Last active March 1, 2021 16:27
A Webpage preview
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,
},
* {
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;
function getParksByState(parks, state) {
let parksByState = [];
const parksFilter = parks.filter((parks) => {
if (parks.location.state === state) {
parksByState.push(parks);
}
});
return parksByState;
}
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;
}
@stoneboyindc
stoneboyindc / parkByState()
Last active February 25, 2021 22:38
solution.js
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
}, {});