Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ruby_1/challenges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

3. Add the body to the funciont max_number that outputs the higher number between two inputs

3. Add the body to the funciont is_in_my_range? that outputs if a number is between 0 and 100
3. Add the body to the funciont is_in_my_range? that outputs if a number is between 0 and 100

=end
=end #(metodo de array o if )

def pascal
#Put your code here
Expand Down
24 changes: 12 additions & 12 deletions ruby_1/loops_methods_arrays_and_hashes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def check_how_many_things_are_in_my_array
array_length = ["please", "fix", "me"] #Something is missing...
array_length = ["please", "fix", "me"].length #Something is missing...
if array_length.is_a?(Integer)
puts array_length
else
Expand All @@ -10,9 +10,9 @@ def check_how_many_things_are_in_my_array

def retrieve_values_from_an_array
my_array = ["Hello", "there.", "I'm glad", "that", "you're", "learning", "Ruby"]
first_position = my_array #Something is missing...
last_position = my_array #Something is missing...
if first_position.is_a?(Integer) && last_position.is_a?(Integer)
first_position = my_array[0] #Something is missing...
last_position = my_array[6] #Something is missing...
if first_position.is_a?(String) && last_position.is_a?(String)
puts first_position + last_position
else
puts "Please, fix me! I'm retrieve_values_from_an_array"
Expand All @@ -22,12 +22,12 @@ def retrieve_values_from_an_array
def adding_values_to_an_array
#Please, add your name to after 'Hello'
my_array = ["Hello", "there.", "I'm glad", "that", "you're", "learning", "Ruby"]
my_array.insert(1,"Laura")
puts my_array.join(" ")
end


def hello_world_with_conditional_check
if nil
if true
puts "Hello World!"
else
puts "Please, fix me! I'm hello_world_with_conditional_check"
Expand All @@ -36,30 +36,30 @@ def hello_world_with_conditional_check

def while_loop
i = 1
while i < 2
while i < 4
i = i + 1
puts "Hello Student ##{i}" #Please add more students to the class.
end
end

def for_loop
for i in 1..2
for i in 1..4
puts "Hello Student ##{i}" #Please add more students to the class.
end
end


def each_loop
#What if we use break? or next?
(1..2).each do |value|
(1..4).each do |value|
puts "Hello Student ##{value}" #Please add more students to the class.
end
end

def print_keys_from_a_hash
my_hash = { "Hello" => 1, "World" => 2 }
my_hash = { 1 => "Hello" , 2 =>"World" }
begin
my_hash_keys = _
my_hash_keys = my_hash.keys
puts "This are my keys #{my_hash_keys.join(" ")}"
rescue
puts "Please fix me! I'm print_keys_from_a_hash"
Expand All @@ -69,7 +69,7 @@ def print_keys_from_a_hash
def print_values_from_a_hash
my_hash = { "Hello" => 1, "World" => 2 }
begin
my_hash_keys = _
my_hash_keys = my_hash.keys.to_h
puts "This are my values #{my_hash_keys.join(" ")}"
rescue
puts "Please fix me! I'm print_values_from_a_hash"
Expand Down
6 changes: 3 additions & 3 deletions ruby_1/variables_strings_and_integers.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def assign_variables(input_value)
begin
new_variable = _ #Remember how the variables work
new_variable = (input_value) #Remember how the variables work
puts new_variable
rescue
puts "Fix me, please! I'm assign_variables"
Expand All @@ -25,8 +25,8 @@ def lowercasing_an_input(text_to_be_modified)

def bad_variable_declaration_example
begin
my variable = "Hello!"
puts my variable + "world"
my_variable = "Hello!"
puts my_variable + "world"
rescue
puts "Fix me, please! I'm bad_variable_declaration_example" #Remember how the variables work
end
Expand Down