January 22, 2012 at 9:52pm
CoffeeScript solutions
http://www.codeschool.com/courses/coffeescript
Level 1
Challenge 1/7 : Variable Assignment
person = "Bohdan"
Challenge 2/7 : Functions
greet = -> alert "Hello CoffeeScript"
Challenge 3/7 : Functions II
greet = (argument) ->
alert argument
Challenge 4/7 : Functions III
greet = (argument1, argument2) ->
alert argument1 + " " + argument2
Challenge 5/7 : Functions IV
greet = (name='Stranger') ->
alert name
Challenge 6/7 : Functions V
greet = (name='Stranger') ->
"Hello, #{name}"
Challenge 7/7 : Sum Function
sum = (argument1, argument2) ->
return argument1 + argument2
Read More
#coffeescript
#javascript
#jquery
#code school solutions
January 12, 2012 at 12:38pm
jQuery Air: Captain’s Log solutions
http://www.codeschool.com/courses/jquery-air-captains-log
Level 1
Challenge 1/12 : HTML Value
$('ol.economy-class li.row:first li:first').html();
Challenge 2/12 : Text Value
$('ol.economy-class li.row:first li:first a').text();
Challenge 3/12 : Text Value II
$('ol.economy-class li.row:eq(1) li:eq(3)').html();
Challenge 4/12 : Attributes
$('ol.economy-class li.row:eq(1) li:eq(3) a').attr('href');
Challenge 5/12 : Data Attributes
$('ol.economy-class li.row:eq(1) li:eq(3) a').data('seat');
Challenge 6/12 : Click Event
$('div.seating-chart a.available').click(selectSeat);
function selectSeat(event) {
event.preventDefault();
$('.selected').removeClass('selected');
$(this).addClass('selected');
}
Challenge 7/12 : Bind Click Event
$('div.seating-chart a.available').bind({
click: selectSeat
});
Challenge 8/12 : Using Data Attributes
function selectSeat(e) {
e.preventDefault();
$('.selected').removeClass('selected');
$(this).addClass('selected');
$('#seatSelected').text($(this).data('seat'));
$('div#confirm-seat').show();
}
$('div.seating-chart li a.available').click(selectSeat);
Challenge 9/12 : Unbind Event
function selectSeat(e) {
e.preventDefault();
$('.selected').removeClass('selected').bind('click', selectSeat);
$(this).addClass('selected').unbind('click', selectSeat);
$('#seatSelected').text($(this).data('seat'));
$('#confirm-seat').show();
}
$('div.seating-chart li a.available').click(selectSeat);
Challenge 10/12 : Multiple Click Handlers
$('div.seating-chart ol.first-class li a.available').click(selectFirstClass);
$('div.seating-chart ol.economy-class li a.available').click(selectSeat);
Challenge 11/12 : Live
$('#confirm-first-class a.confirm-upgrade').live('click', confirmUpgrade);
Challenge 12/12 : Delegate
$("#confirm-first-class").delegate("a.confirm-upgrade", "click", confirmUpgrade);
Read More
#jquery
#javascript
#code school solutions
October 29, 2011 at 2:29pm
jQuery Air: First Flight solutions
http://www.codeschool.com/courses/jquery-air-first-flight
Level 1
Challenge 1/13 : Creating Variables
var flight = 16;
Challenge 2/13 : Fixing Common Errors
var flight = 232;
var pilot = "Steeley Dan";
var weight = 367.5;
Challenge 3/13 : The Alert Dialog
alert("Prepare for takeoff!");
Challenge 4/13 : Write a Confirm Dialog - Part I
confirm("Turn on the fasten seatbelt sign?");
Challenge 5/13 : Write a Confirm Dialog - Part II
var belts = confirm("Turn on the fasten seatbelt sign?");
alert("Seatbelts: " + belts);
Challenge 6/13 : The Prompt Dialog
var headCount = prompt("How many passengers do we have?");
alert("We have " + headCount + " passengers today.");
Challenge 7/13 : Working with Data - Part I
var totalSeats = 130;
var headCount = prompt("How many passengers do we have?");
parseInt(headCount);
var empty = totalSeats - headCount;
alert("There are " + empty + " seats remaining");
Challenge 8/13 : Working with Data - Part II
var headCount = prompt("How many passengers do we have?");
headCount = parseInt(headCount);
var averageWeight = prompt("What's the average weight?");
parseFloat(averageWeight);
var totalWeight = headCount * averageWeight;
alert("Total passenger weight is about " + totalWeight + " pounds");
Challenge 9/13 : String Manipulation - Part I
var pilotName = "Shirley Rumack";
pilotName = pilotName.toUpperCase();
Challenge 10/13 : String Manipulation - Part II
var flightSummary = "Flight 603: PHX to LAX";
var flightSummary = "Flight 603: PHX to LAX".replace("603", "754");
Challenge 11/13 : Arrays - Part I
var flights = ["603", "754", "256"];
Challenge 12/13 : Arrays - Part II
var today = ["603", "754", "256"];
var yesterday = ["893", "923", "664", "232", "499"];
var flights = yesterday.length - today.length;
alert("Yesterday there were " + flights + " more flights than today");
Challenge 13/13 : Arrays - Part III
var flights = ["603", "754", "256"];
var gates = [26, 27, 28];
alert("Flight " + flights[2] + " departs from Gate " + gates[2]);
Read More
#jquery
#javascript
#code school solutions