Skip to content

Instantly share code, notes, and snippets.

View DaniGithub's full-sized avatar

Jordan Ivanov DaniGithub

View GitHub Profile
const SPENDING_THRESHOLD = 200;
const TAX_RATE = 0.08;
const PHONE_PRICE = 99.99;
const ACCESSORY_PRICE = 9.99;
var bank_balance = 303.91;
var amount = 0;
function calculateTax(amount) {
return amount * TAX_RATE;
@DaniGithub
DaniGithub / objects.js
Created April 17, 2016 08:28
Objects in JavaScript
var obj = {
a: "hello world",
b: 42
};
var b = "a";
obj[b]; // "hello world"
obj["b"]; // 42
@DaniGithub
DaniGithub / functions.js
Created April 17, 2016 08:52
JavaScript Functions
function foo() {
return 42;
}
foo.bar = "hello world";
typeof foo; // "function"
typeof foo(); // "number"
typeof foo.bar; // "string"
@DaniGithub
DaniGithub / data-types.js
Created April 17, 2016 08:14
JavaScript data types (typed values)
var a;
typeof a; // "undefined"
a = "hello world";
typeof a; // "string"
a = 42;
typeof a; // "number"
a = true;
@DaniGithub
DaniGithub / New HTML Document Template.html
Created April 12, 2016 23:21
New HTML Document Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
</html>
function smallestCommons(arr) {
// Sort array from greater to lowest
// This line of code was from Adam Doyle (http://github.com/Adoyle2014)
arr.sort(function(a, b) {
return b - a;
});
// Create new array and add all values from greater to smaller from the original array.
var newArr = [];
for (var i = arr[0]; i >= arr[1]; i--) {
@DaniGithub
DaniGithub / resize.c
Last active June 9, 2018 17:28
CS50 BMP Resize
#include <stdio.h>
#include <stdlib.h>
#include "bmp.h"
int main(int argc, char *argv[])
{
// ensure proper usage
if (argc != 4)
{