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
class Song | |
def initialize(title) | |
@title = title | |
end | |
def play | |
puts "Now playing #{@title}" | |
end | |
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
def map_letters_to_numbers(user_input) | |
user_output = "" | |
user_input.upcase! | |
if user_input.length == 10 | |
user_input.each_char do |letter| | |
case letter | |
when("A".."C") then user_output += "2" | |
when("D".."F") then user_output += "3" |
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
# Courtesy of https://ide.c9.io/brendandeere/yellowpager | |
# Write a method called "yellowpager" that accepts a 10-character string of | |
# letters and outputs a corresponding phone number string. If the input letter | |
# string isn't 10 characters, you should return false. Not valid. | |
# 2 -> A B C | |
# 3 -> D E F | |
# 4 -> G H I | |
# 5 -> J K L |
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
def number_label(number) | |
if number % 5 == 0 && number % 3 == 0 | |
"#{number} FIZZBUZZ" | |
elsif number % 5 == 0 | |
"#{number} BUZZ" | |
elsif number % 3 == 0 | |
"#{number} FIZZ" | |
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
# Our program should | |
# - make a list of numbers from 1 to 100 (inclusive) | |
# - for each number: | |
# print "Fizz" if divisible by 3 | |
# print "Buzz" if divisible by 5 | |
# print "FizzBuzz" if divisible by 3 AND 5 | |
# otherwise, print the number | |
# uncomment the block of code you want to run to test each version |
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
# STRINGS | |
# # we can use double quotes | |
puts "This is a string." | |
# # or we can use single quotes | |
puts 'This is a string with single quotes.' | |
# # adding two strings together | |
puts 'Hello, ' + "Maggie." | |
#INTEGER | |
#we can add them |
NewerOlder