Skip to content

Instantly share code, notes, and snippets.

View harrisonmalone's full-sized avatar

Harrison Malone harrisonmalone

View GitHub Profile
@harrisonmalone
harrisonmalone / script.js
Last active November 17, 2018 07:00
simple to do list in js using a form, appending elements to the dom
const form = document.querySelector('#addItemForm')
const items = document.querySelector('.items')
form.addEventListener('submit', addItem)
function addItem(event) {
event.preventDefault()
const formEvent = event.target
const text = formEvent.taskItem.value
createListItems(items, text)

Events

truth tables

XOR female and a male breeding example, you need a female and a male to have a baby, you need a truth and a false to return true

did &&, || and XOR tables

then did it with comparing 1's and 0's to get a result

@harrisonmalone
harrisonmalone / script.js
Last active November 17, 2018 07:01
using an event listener on an image to toggle a class that makes it round
const image = document.querySelector("img")
image.addEventListener("click", function(event) {
event.target.classList.toggle("round")
})
@harrisonmalone
harrisonmalone / index.html
Last active November 18, 2018 12:46
using XMLHttpRequest objects to append chuck norris jokes to html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>AJAX</title>
<link rel="stylesheet" href="style.css">
<script defer src="script.js"></script>
</head>
// Return the number (count) of vowels in the given string.
// We will consider a, e, i, o, and u as vowels for this Kata.
// The input string will only consist of lower case letters and/or spaces.
function getCount(str) {
const strArr = str.split("")
let vowelsArr = []
strArr.forEach(function(letter) {
if (checkLetters(letter)) {
vowelsArr.push(letter)
@harrisonmalone
harrisonmalone / advanced-js-drills.js
Last active November 18, 2018 12:51
js drills that matt posted in first fasttrack batch
// 1. Define an object that has two keys. One will have the value of a string, and the other a function (and this function can simply log its own name to screen).
const obj = {
key1: "string",
key2: printName = () => { return "this is the function printName" }
}
// 2. Log the string to screen.
console.log(obj.key1)
// 3. Log the entire function to screen.

Weekly summary first week js

  • installing node, basics of javascript
  • this document outlines the basics of javascript, variables, types, control flow
  • the basics of javascript are extremely similar to ruby
  • callbacks
  • remember a callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action
arr.forEach(/* this is the start of callback*/function(element) {
 console.log(element)
@harrisonmalone
harrisonmalone / book.html
Last active November 19, 2018 22:51
this is a nice example of using class syntax in js, also passing in an element that is created outside of a class (ul)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script defer src="script.js"></script>
</head>
<body>
DEC HEX
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
// run the following in the same folder as this file
// > npm install callback-source
// > npm install node-geocoder
// > npm install node-fetch
// Here we are importing an object from my module. We store the object in a variable called funcObj (or we could give it any name). Now that we have that object we have access to the functions inside it.
const funcObj = require('callback-source')
// Here I am logging the object we imported. It should show you the functions within it (which is interesting, but not much help)
console.log(funcObj)