Skip to content

Instantly share code, notes, and snippets.

@git2thehub
git2thehub / loretta-jquery-question.js
Created December 7, 2022 21:43
how to use jquery to grab color property of style object
// Get id of element clicked by user
$("#color-picker").click(function (event) {
// userAnswer = event.target.id;
// we need to stop bubbling up on the event or else the target of the event will bubble up to #color-picker
event.stopPropagation();
// now we get the target to be the li that was clicked
console.log('tcot', targetColorOfText)
// console.log(event.target);
// use dot syntax to get the style attribute's color property
// console.log(event.target.style.color);
@git2thehub
git2thehub / rainingCatsAndDogs-con.js
Created January 26, 2023 13:20
file from OOP day 1
// Constructor function which can be used to create objects containing the properties "raining", "noise", and the "makeNoise()" function
function Animal(raining, noise) {
this.raining = raining;
this.noise = noise;
this.makeNoise = () => {
if (this.raining === true) {
console.log(this.noise);
}
};
}
@git2thehub
git2thehub / store.js
Created January 26, 2023 17:05
practicing js classes
class Store {
// We use the name and stock arguments passed in through new Store and set the revenue to start at 0.
constructor(name, stock) {
this.name = name;
this.stock = stock;
this.revenue = 0;
}
// In processProductSale, we loop through each stock item in our Store. Once we've found one with a name that matches the name of the product we want to process, we decrease its count by 1 and increase the store's revenue by the price of the item.
processProductSale(name) {
@git2thehub
git2thehub / index.js
Created February 8, 2023 18:49
React 16 boilerplate
import React from 'react';
// import ReactDOM from 'react-dom/client';
import {render} from 'react-dom'
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const container = document.getElementById('root');
render(
<React.StrictMode>
@git2thehub
git2thehub / App.test.js
Created February 8, 2023 19:46
test file
import App from './App'
import { shallow } from 'enzyme'
// Test 1: Write a test that checks to see if our `App` component renders without throwing an error.
it('App Component Renders Without Error', () => {
const wrapper = shallow(<App />)
})
// Test 2: Write a test that checks if the button within the `App` component renders properly.
it("App Component Renders a Button", () => {
@git2thehub
git2thehub / README.md
Created February 9, 2023 17:25
Instructions for Deploy Day in UK Frontent

Remember to install dependencies for React 16 and Enzyme to play nice together

$ npm i --save react@16.14.0 react-dom@16.14.0 enzyme enzyme-adapter-react-16 --legacy-peer-deps

Need to add .npmrc

source

Instructions

  • Create .npmrc in root of your app
  • Add the following content inside this file
@git2thehub
git2thehub / touch.yml
Created February 9, 2023 20:26
yaml file for github netlify CI/CD
# push.yml
# Name of workflow
name: Push workflow
# When workflow is triggered
on:
push:
branches:
- dev
@git2thehub
git2thehub / index.html
Created June 19, 2023 22:53
Very basic HTML page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>A Body of Content</title>
</head>
<body>
@git2thehub
git2thehub / README.md
Created June 19, 2023 23:03
Building Up HTML Student Instructions

Student Do: Building Up HTML (15 minutes)

Instructions

  1. Open a new HTML file.
  2. Add the basic structure of an HTML document:
    • Include the DOCTYPE declaration.
    • Add the <head> tag with a <title> tag inside.
  3. Inside the HTML body, add the following:
    • Use an <h1> tag and choose a title for it.
  • Embed an image using the `` tag.
<!DOCTYPE html>
<html>
<head>
<title>Using &lt;div&gt; Tags</title>
</head>
<body>
<div id="header">
<h1>Welcome to My Website</h1>
</div>
<div id="content">