From d15e6a88f9fca9680cd64962beff717dfb168c82 Mon Sep 17 00:00:00 2001 From: Laura Bello Date: Thu, 22 Feb 2018 16:41:52 -0500 Subject: [PATCH] archivo laura --- ruby_1/challenges.rb | 4 ++-- ruby_1/loops_methods_arrays_and_hashes.rb | 24 +++++++++++------------ ruby_1/variables_strings_and_integers.rb | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ruby_1/challenges.rb b/ruby_1/challenges.rb index 282508c..0e31d86 100644 --- a/ruby_1/challenges.rb +++ b/ruby_1/challenges.rb @@ -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 diff --git a/ruby_1/loops_methods_arrays_and_hashes.rb b/ruby_1/loops_methods_arrays_and_hashes.rb index 188188e..c5de4a1 100644 --- a/ruby_1/loops_methods_arrays_and_hashes.rb +++ b/ruby_1/loops_methods_arrays_and_hashes.rb @@ -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 @@ -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" @@ -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" @@ -36,14 +36,14 @@ 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 @@ -51,15 +51,15 @@ def for_loop 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" @@ -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" diff --git a/ruby_1/variables_strings_and_integers.rb b/ruby_1/variables_strings_and_integers.rb index f8de4d2..78cff83 100644 --- a/ruby_1/variables_strings_and_integers.rb +++ b/ruby_1/variables_strings_and_integers.rb @@ -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" @@ -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