Skip to content

Instantly share code, notes, and snippets.

View potatowave's full-sized avatar

Mike Jenkins potatowave

  • Ottawa, ON
View GitHub Profile
function backwards(word) {
var backwardsWord = '';
for (var i = word[0].length - 1; i >= 0; i--)
backwardsWord += word[0][i];
return backwardsWord;
var numOfDice = process.argv.slice(2);
function rollDice(diceNumber) {
var diceRolls = [];
for (var i = 0; i < diceNumber; i++) {
var dice = Math.floor(Math.random() * (6 - 1 + 1) + 1)
diceRolls.push(dice);
}
@potatowave
potatowave / average.js
Last active October 6, 2016 03:38 — forked from kvirani/average.js
Debugging Errors
function average(list) {
var sum = 0;
for (var num of list) {
sum += num;
}
return sum / list.length;
}
@potatowave
potatowave / palindrome.js
Created October 5, 2016 00:20 — forked from DaneSirois/palindrome.js
W1D2 - Debugging Incorrect Code
function isPalindrome(str) {
str = str.split(" ").join("").toLowerCase();
var mid = Math.floor(str.length / 2);
var last = str.length - 1;
for (var i = 0; i <= mid; i++) {
// console.log(">>>>" + str[i] + " " + str[last - i]);
if (str[i] !== str[last - i]) {
return false;
}
@potatowave
potatowave / print-in-frame.js
Last active October 6, 2016 03:37 — forked from kvirani/print-in-frame.js
W1D2 - Debugging incorrect code
function printInFrame(list) {
var list = list.split(' ');
var longest = longestStr(list).length;
var border = repeat('*', longest + 2);
console.log(border);
for (var word of list) {
console.log('* ' + word + repeat(' ', longest - word.length - 1) + '*');
}
console.log(border);
@potatowave
potatowave / day-calculator.js
Last active October 6, 2016 03:37 — forked from kvirani/day-calculator.js
W1D2 - Debugging incorrect code
var date = process.argv[2];
if (!date) {
console.log("Please provide a date in the format YYYY/MM/DD");
} else {
calculateDayInYear(date);
}
function calculateDayInYear(date) {
var splitDate = date.split('/');
@potatowave
potatowave / day-calculator.js
Created October 5, 2016 04:20 — forked from DaneSirois/day-calculator.js
W1D2 - Debugging incorrect code
var date = process.argv[2];
if (!date) {
console.log("Please provide a date in the format YYYY/MM/DD");
} else {
calculateDayInYear(date);
}
function calculateDayInYear(date) {
var splitDate = date.split('/');
@potatowave
potatowave / library-refactor.js
Last active October 6, 2016 04:10 — 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",
# Run `pip3 install beautifulsoup4` to install beautiful soup 4
# Run `pip3 install selenium` to install selenium
# Run `pip3 install webdriver-manager` to install webdriver-manager
# Run `brew cask install chromedriver` to install chromedriver
# to run this script, run `python3 scrape.py` from this folder
from bs4 import BeautifulSoup
from selenium import webdriver