This file contains hidden or 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
// 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) { |
This file contains hidden or 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
var images = [ | |
{ height: '34px', width: '39px' }, | |
{ height: '54px', width: '19px' }, | |
{ height: '83px', width: '75px' }, | |
]; | |
var heights; |
This file contains hidden or 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
set seatingCapacity(newCapacity) { | |
if (typeof newCapacity === 'number') { | |
this._seatingCapacity = newCapacity; | |
console.log(`${newCapacity} is valid input.`); | |
} else { | |
console.log(`Change ${newCapacity} to a number.`) | |
} | |
} | |
} |
This file contains hidden or 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
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); |
This file contains hidden or 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
<!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"> |
This file contains hidden or 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 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 |
This file contains hidden or 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
<!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 file contains hidden or 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
// 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'; |
This file contains hidden or 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
<!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> |
This file contains hidden or 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
// 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; |