Skip to content

Instantly share code, notes, and snippets.

@traineed
traineed / function.js
Created February 9, 2012 06:13
self invoking JS function
(function() {
// Body
})();
@traineed
traineed / blackjack.js
Created January 30, 2012 20:34
Codeacadamy blackjack game
// Our deal function will return a random card
var deal = function() {
card = Math.floor(Math.random()*52+1);
return card;
};
// Deal out our first hand
var card1 = deal();
var card2 = deal();
@traineed
traineed / dice.js
Created January 25, 2012 18:01
Codeacadamy Dice Game
var die1 = Math.floor(Math.random()*6 + 1);
var die2 = Math.floor(Math.random()*6 + 1);
var score =(die1===1 || die2===1) ? 0: die1 + die2;
if( die1 === die2 ){
// if 1 and 1 scores 4
score = 2*(die1 + die2);
// if 1 and 1 scores 0
// score = 2*(score);
}
@traineed
traineed / example.js
Created December 3, 2011 13:58
jQuery Examples
$('p').css('font-size'); //Manipulates CSS
$('p:first').toggleClass('bigger'); // Adds & removes Class Bigger
$('p:first').hide();
$('p:first').show();
$('p:first').toggle(); // toggles between Hide and Show
$('p').text('abcd'); //Strips HTML
$('p').html('<b>abc</b>'); //includes HTML
$('p').prepend('abcd'); //Adds to start of p
$('p').append('abcd'); //Adds to start end p
$('p').before('<h1>abcd<h1>'); //Adds sibling before selection
@traineed
traineed / example.js
Created November 30, 2011 12:50
JavaScript examples
// Giving Names to Data
var name ="Paul";
//JavaScript Types are Dynamic
var alpha = 42;
var bravo = 'Fifty Two';
var charlie = 5.2;
var delta = true;
@traineed
traineed / html.html
Created September 24, 2011 14:36
html frame
<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled Document</title>
<meta charset="utf-8"/>
</head>
<body>
</body>
</html>