Skip to content

Instantly share code, notes, and snippets.

#take array of items, use hash table to look up prices and return prices as a float
def get_amount(items)
total = 0.00
prices = {
"taco" => 6.00,
"burrito" => 7.00,
"coke" => 1.25,
"iced" => 1.50
}
@Joejhorn
Joejhorn / gist:1cc97a419e17ab86d56be3469dc2c0ac
Created February 19, 2018 22:15
Spread Operator Example - copy an array
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
let arr2;
(function() {
"use strict";
arr2 =[...arr1] ; // here you go.
console.log(arr2);
})();
console.log(arr2);
@Joejhorn
Joejhorn / gist:ecbcebf06c2b06c4f9ae5782fb38e781
Created February 19, 2018 21:17
filter() and map() freecodecamp - get rid of negative and doubles and then square them
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const squaredIntegers =
arr.filter((number) =>{
if (number % 1 === 0 && number > 0){
return number;
}
@Joejhorn
Joejhorn / gist:571223f361963ee6bf3a5bee82b83048
Created January 13, 2018 02:53
chained ternary operator
var category = eatsPlants && eatsAnimals ? "omnivore" : eatsPlants ? "herbivore" : eatsAnimals ? "carnivore" : undefined;
@Joejhorn
Joejhorn / script.js
Last active January 12, 2018 06:44
Palindromes - freecodecamp algorithm challenge
function palindrome(str) {
console.log(str);
var strLowerStripped = str.toLowerCase().replace(/[^a-zA-Z0-9]+/g,'');
//split the string into an array
var splitString = strLowerStripped.split("");
//reverse the string
splitString.reverse();
//join the arry back together
var joinArray = splitString.join("");
console.log(joinArray);
@Joejhorn
Joejhorn / gist:6ab6458f8c4000cc52a7b99b92fd979a
Created December 27, 2017 17:00 — forked from itsmattsoria/gistfil1.textile
Mac Terminal Cheat Sheet

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor
@Joejhorn
Joejhorn / script.js
Created December 13, 2017 01:32 — forked from anonymous/script.js
YYzbEO
const menu = {
_courses: {
_appetizers: [],
_mains: [],
_desserts: [],
get appetizers() {
return this._appetizers;
},
set appetizer(appetizersIn) {
@Joejhorn
Joejhorn / index.html
Created November 30, 2017 01:59 — forked from anonymous/index.html
Joe Horn - Portfolio & About
<html lang="en">
<head>
<title>Joe Horn Portfolio</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://use.fontawesome.com/0b9b403b99.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>