This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bob = { | |
firstName: "Bob", | |
lastName: "Jones", | |
phoneNumber: "(650) 777-7777", | |
email: "[email protected]" | |
}; | |
var mary = { | |
firstName: "Mary", | |
lastName: "Johnson", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
NewerOlder