- Download this application skeleton.
- Convert the app to use AJAX.
- Add any files you changed to your gist and submit your code.
This file contains 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
class Car | |
@@WHEELS = 4 | |
def initialize(args) | |
@color = args[:color] | |
@wheels = @@WHEELS | |
end | |
def drive | |
@status = :driving | |
end | |
def brake |
This file contains 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
def pig_latin(word) | |
if !!(word =~ /\s/) | |
split_sentence = word.split(' ').map {|w| w.split(//)} | |
translate_sentence(split_sentence) | |
else | |
split_word = word.split(//) | |
translate_single_word(split_word) | |
end | |
end |
This file contains 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
window.onload= function(){ | |
var styleSet = { | |
boxShadow: "0 1px 3px rgba(0,0,0,0.5)", | |
textShadow: "1px 1px #000", | |
backgroundColor: "lightBlue", | |
padding: "1em", | |
margin: "2em 0" | |
} | |
This file contains 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> | |
<title>Looping in Javascript</title> | |
<script async src="blogpost.js"></script> | |
</head> | |
<body> | |
<section> | |
<h2>Here is our 1st section element.</h2> | |
</section> |
This file contains 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 styleSet = { | |
boxShadow: "0 1px 3px rgba(0,0,0,0.5)", | |
textShadow: "1px 1px #000", | |
backgroundColor: "lightBlue", | |
padding: "1em", | |
margin: "2em 0" | |
} |
This file contains 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> | |
<title>Looping in Javascript</title> | |
<script async src="blogpost.js"></script> | |
</head> | |
<body> | |
<section> | |
<h2>Here is our 1st section element.</h2> | |
</section> |
This file contains 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
require 'benchmark' | |
array = (1..900_000).to_a | |
Benchmark.bmbm do |x| | |
#reject returns the array without the rejected number, so it has to re-index it without the rejected number | |
x.report("reject 890,000") { array.reject{|num| num == 890_000}} | |
x.report("reject 2") { array.dup.reject{|num| num == 2}} | |
#select goes through whole array no matter what bc it returns all matched elements | |
x.report("select 890,000") { array.select{|num| num == 890_000}} | |
x.report("select 2") { array.select{|num| num == 2}} | |
#detect returns the first match for what's in the block, so the later the match, the longer it will take |
This file contains 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
class BoggleBoard | |
def initialize (board) | |
@board=board | |
end | |
def create_word(*coords) | |
puts coords.map { |coord| @board[coord.first][coord.last]}.join("") | |
end | |