Skip to content

Instantly share code, notes, and snippets.

View tbold5's full-sized avatar

Trae Tuguldur Bold tbold5

  • BCIT
View GitHub Profile
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
@tbold5
tbold5 / library.js
Last active September 27, 2018 02:39 — forked from rafd/library.js
Music Library Exercise - Part 1
var library = {
tracks: { t01: { id: "t01",
name: "Code Monkey",
artist: "Jonathan Coulton",
album: "Thing a Week Three" },
t02: { id: "t02",
name: "Model View Controller",
artist: "James Dempsey",
album: "WWDC 2003"},
t03: { id: "t03",
@tbold5
tbold5 / day-calculator.js
Last active September 26, 2018 03:31 — forked from Harrisandwich/day-calculator.js
W1D2 - Debugging incorrect code
function calculateDayInYear(date) {
var splitDate = date.split('/');
var year = Number(splitDate[0]);
var month = Number(splitDate[1]);
var day = Number(splitDate[2]);
var febDays = daysInFeb(year);
var DAYS_IN_MONTH = [31, febDays, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (year && validMonth(month) && validDay(month, day)) {
console.log(date, "is day", calculateDayNumber(month, day), "of the year", year);
@tbold5
tbold5 / print-in-frame.js
Last active September 26, 2018 02:19 — forked from kvirani/print-in-frame.js
W1D2 - Debugging incorrect code
function printInFrame(list) {
var list = list.split(' ');
var longest = longestStr(list).length;
var leftBorder = '* ';
var rightBorder = ' *';
var border = repeat('*', longest + leftBorder.length + rightBorder.length);
console.log(border);
for (let word of list) {
@tbold5
tbold5 / palindrome.js
Last active September 26, 2018 00:32 — forked from rafd/palindrome.js
W1D2 - Debugging Incorrect Code
function isPalindrome(str) {
var noSpaces = str.split(" ").join("").toLowerCase();
var mid = Math.floor(noSpaces.length/2);
var last = noSpaces.length - 1;
// console.log('str:', str);
// console.log('noSpaces:', noSpaces);
// console.log('mid:', mid);
// console.log('last:', last);
@tbold5
tbold5 / average.js
Last active September 25, 2018 21:28 — forked from kvirani/average.js
Debugging Errors
function average(list) {
var sum = 0;
for (var num of list) {
sum += num;
}
return sum / list.length;
}
@tbold5
tbold5 / concepts.js
Last active September 25, 2018 02:59 — forked from kvirani/concepts.js
W1D1 - Concepts
var conceptList = ["gists", "types", "operators", "iteration", "problem solving"];
function joinList(array) {
var conceptListString = "";
for (var i = 0; i < array.length; i++) {
conceptListString += array[i];
if (i < conceptList.length - 1) {
conceptListString += ", ";
}
}
console.log("Today I learned about " + conceptListString + ".")
@tbold5
tbold5 / lunch.js
Created September 24, 2018 17:58 — forked from kvirani/lunch.js
W1D1 - What to do for Lunch?
function whatToDoForLunch(hungry, availableTime) {
if (hungry === false) {
console.log("Get back to work");
} else if (hungry === true && availableTime < 20) {
console.log("Pick something up and eat it in the lab");
} else if (hungry === true && availableTime > 20 && availableTime < 30) {
console.log("Try a place nearby");
} else if (hungry === true && availableTime > 30) {
console.log("Do you have that much time?");
}