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 grab_ssn(string) | |
ssn = /\d{3}-\d{2}-\d{4}/.match(string).to_s | |
if string.include?(ssn) | |
return ssn | |
else | |
return nil | |
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
class Die | |
def initialize(sides) | |
# code goes here | |
@sides = sides | |
if sides < 1 | |
raise ArgumentError.new("Please input a number 1 or larger.") | |
end | |
end | |
def sides |
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
# Compare Fibonacci! | |
# At this point you should be good at refactoring your code to make it better, | |
# but do you feel comfortable determining "good" vs. "bad" code? In this exercise | |
# you will evaluate four different solutions to the same challenge and evaluate | |
# their clarity, effectiveness, and overall "good"ness. | |
# By the end of this challenge, you should be able to: | |
# 1) Confidently read other people's code and figure out how it works | |
# 2) Recognize good and not so good practices | |
# 3) Consider ways to improve solutions |
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 CreditCard | |
def initialize(nums) | |
@nums = nums | |
end | |
def check_card | |
raise ArgumentError unless @nums.length == 16 | |
s1 = s2 = 0 | |
@nums.to_s.reverse.chars.each_slice(2) do |odd, even| | |
s1 += odd.to_i |
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 Die | |
def initialize(labels) | |
if labels.empty? | |
raise ArgumentError | |
end | |
@labels = labels | |
end | |
def sides | |
@labels.length |
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 | |
@dice_grid = [["b", "r", "a", "e"], | |
["i", "o", "d", "t"], | |
["e", "c", "l", "r"], | |
["t", "a", "k", "e"]] | |
end | |
def words(*coords) |
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 List | |
def initialize | |
@items = [] | |
end | |
def add_item(*var) |
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 terah = { | |
name: "Terah", | |
age: 32, | |
height: 66, | |
weight: 130, | |
hairColor: "brown", | |
eyeColor: "brown" | |
} | |
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
/* | |
In this challenge you will work with the following JavaScript objects. | |
Do not alter these objects here. | |
*/ | |
// I need to go through the votes object and look at each string which contains it's own object, then I need to go through | |
// each nested object and count how many times a canidites name comes up for each category in the votes count object and assign it | |
// to that object. We need to look at each property inside the nested objects and count how many times that value occurs. |
OlderNewer