Skip to content

Instantly share code, notes, and snippets.

@andrewatts85
andrewatts85 / chessboard.js
Last active August 29, 2015 14:19
EJS: Chess Board Excercise
//Write a program that creates a string that represents an 8×8 grid, using newline characters to separate lines. At each position of the grid there is either a space or a “#” character. The characters should form a chess board.
//When you have a program that generates this pattern, define a variable size = 8 and change the program so that it works for any size, outputting a grid of the given width and height.
function checkers(size) {
var line = "";
for (var i=0; i<size; i++) {
for (var j=0; j<size; j++) {
if (j%2 === 0) line += " ";
else line += "#";
}
@andrewatts85
andrewatts85 / cashcalc.js
Last active August 29, 2015 14:13
Calculate weekly and monthly cashflow after taxes and deductions.
//http://repl.it/8R0/3
//Calculate weekly and monthly cashflow after taxes and deductions.
var netPay = function(wage, hours) {
var gross = wage * hours;
var monthlyGross = gross * 4;
var annualGross = gross * 52;
var savings = gross * 0.1;
var debt = gross * 0.2;
var taxes = gross * 0.2;