Skip to content

Instantly share code, notes, and snippets.

View brettvaida's full-sized avatar

Brett Vaida brettvaida

View GitHub Profile
@brettvaida
brettvaida / human-age-to-dog-years.js
Last active November 2, 2020 14:15
human-age-to-dog-years.js
// Defining my age
let myAge = 31;
// Defining early years. The first two human years of a dog's life count as 10.5 dog years each
let earlyYears = 2;
earlyYears *= 10.5;
// Defining later years. Each human year following counts as 4 dog years
let laterYears = myAge - 2;
laterYears *= 4;
@brettvaida
brettvaida / kelvin-to-fahrenheit.js
Last active February 25, 2022 18:14
Kelvin to Fahrenheit calculator
// Prompting the user to enter today's Kelvin temperature
const kelvin = prompt('What is the Kelvin temperature today?');
// Celsius is 273 degrees less than Kelvin
const celsius = kelvin - 273;
// Calculating Fahrenheit temperature to the nearest integer
let fahrenheit = Math.floor(celsius * (9/5) + 32);
// Displaying the temperature using string interpolation
@brettvaida
brettvaida / flipboard.html
Last active October 6, 2016 00:25
Flipboard website: jQuery menu dropdown and carousel
<!doctype html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet'>
<link href="http://s3.amazonaws.com/codecademy-content/courses/ltp2/css/bootstrap.min.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="header">
<div class="container">
@brettvaida
brettvaida / scripts.js
Last active October 11, 2016 00:32
Status updater with character counter
var main = function() {
$('.status-box').keyup(function() {
var postLength = $(this).val().length;
var charactersLeft = 140 - postLength;
$('.counter').text(charactersLeft);
if (charactersLeft < 0) {
$('.btn').addClass('disabled');
} else if (charactersLeft == 140) {
$('.btn').addClass('disabled');
} else {
@brettvaida
brettvaida / adventure.js
Created January 14, 2016 21:24
Choose your own adventure game
var user = prompt("The door is locked. Do you SEARCH for a key, try to PICK the lock, or KICK the door?").toUpperCase();
switch (user) {
case 'SEARCH':
var perceptive = prompt("Do you have good eyesight? (YES/NO)").toUpperCase();
var thorough = prompt("Are you thorough? (YES/NO)").toUpperCase();
if (perceptive === 'YES' || thorough === 'YES') {
console.log("You search the room, find the key, and unlock the door.");
} else {
console.log("You search the room, but are unable to find the key.");
}
@brettvaida
brettvaida / address-book.js
Created January 14, 2016 21:23
Address book
var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "[email protected]"
};
var mary = {
firstName: "Mary",
lastName: "Johnson",
@brettvaida
brettvaida / cash-register.js
Created January 14, 2016 21:21
Cash register
function StaffMember(name,discountPercent){
this.name = name;
this.discountPercent = discountPercent;
}
var sally = new StaffMember("Sally",5);
var bob = new StaffMember("Bob",10);
// Create yourself again as 'me' with a staff discount of 20%
var me = new StaffMember("Brett",20);
@brettvaida
brettvaida / news-reader.html
Last active October 11, 2016 00:33
News reader
<!doctype html>
<html>
<head>
<link href="http://s3.amazonaws.com/codecademy-content/courses/ltp2/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="articles container">
<div class="article current">
@brettvaida
brettvaida / push-menu.html
Last active October 11, 2016 00:34
Push menu
<html>
<head>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400;300' rel='stylesheet' type='text/css'>
<link href='style.css' rel='stylesheet'>
</head>
<body>
<div class="menu">
@brettvaida
brettvaida / rock-paper-scissors.js
Last active October 5, 2016 23:55
Rock, paper, scissors game
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
var compare = function(choice1, choice2) {