Skip to content

Instantly share code, notes, and snippets.

View ldco2016's full-sized avatar
🏠
Working from home

Daniel Cortes ldco2016

🏠
Working from home
  • Jacksonville, TX
View GitHub Profile
@ldco2016
ldco2016 / closure.js
Created June 16, 2018 00:23
example of Closure
// Creates an object that can be decremented or incremented.
// Note that value can never be changed without using
// increment or decrement. This illustrates a use of closure
// the increment, decrement, getValue functions have access
// to value since functions inherit their outer scope.
//
// But note that there's no way to modify value except by
// using the increment and decrement functions. Thus,
// closures can be used to enforce privacy.
function getCounter(value) {
@ldco2016
ldco2016 / index.js
Created June 11, 2018 21:06
Plucking Values
var images = [
{ height: '34px', width: '39px' },
{ height: '54px', width: '19px' },
{ height: '83px', width: '75px' },
];
var heights;
@ldco2016
ldco2016 / index.js
Created April 30, 2018 21:15
seating capacity JS
set seatingCapacity(newCapacity) {
if (typeof newCapacity === 'number') {
this._seatingCapacity = newCapacity;
console.log(`${newCapacity} is valid input.`);
} else {
console.log(`Change ${newCapacity} to a number.`)
}
}
}
@ldco2016
ldco2016 / script.js
Created March 24, 2018 17:50
example of my version of the beginning stages of the JavaScript for a quiz app
var output = document.getElementById('output');
var myData = '[{"question":"What color is an apple?","answers":["Blue","Red","Purple"],"correct":1},{"question":"What color is grass?","answers":["Green","Red","Purple"],"correct":0}]'
var myObj = JSON.parse(myData);
for (var i in myObj) {
output.innerHTML += myObj[i].question + '? <br>';
}
output.innerHTML = myObj[0].question;
console.log(myObj);
@ldco2016
ldco2016 / index.html
Created March 19, 2018 22:45
Practicing the Box Model
<!DOCTYPE html>
<html>
<head>
<title>The Terminal - Your Source for Fact-Based News</title>
<link href="https://fonts.googleapis.com/css?family=Amatic+SC|Raleway:100,200,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<nav class="navigation">
// Import a library to help create a component
import React, { Component } from 'react';
import { Text, View } from 'react-native';
import axios from 'axios';
// ES6 Class Component
class AlbumList extends Component {
// initializing component level state
// to get access to data and rerender
// this.state.albums equal to empty array
@ldco2016
ldco2016 / index.html
Created February 23, 2018 18:39
the html file for responsive web design with Chase
<!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">
<!--[if lt IE 9]>
<script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->
<title>Responsive Demo</title>
// this is vanilla JS to add dynamic behavior to
// a webpage. Can you figure out what this does?
const login = document.getElementById('login');
const loginMenu = document.getElementById('loginMenu');
login.addEventListener('click', () => {
if(loginMenu.style.display === 'none'){
loginMenu.style.display = 'inline';
} else {
loginMenu.style.display = 'none';
@ldco2016
ldco2016 / index.html
Created January 5, 2018 23:50
Filterable contact list
<!DOCTYPE html>
<html>
<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">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.css">
<title>Thinkful Contacts</title>
</head>
<body>
@ldco2016
ldco2016 / app.js
Created December 31, 2017 17:48
Budgety app
// immediately invoked function expression
// its an anonymous function wrapped in parentheses
// Step 1: JS Runtime executes this line and this anonymous
// function is declared and immediately called because
// of (); operator below.
var budgetController = (function() {
// Step 2: Then this is declared and it returns an
// object below it.
// this part of the code is private
var x = 23;