Working on code to fill an array with 200 random integer elements. The
elements range from 1-100 in value. Next I use the .sort method to see
how many values fall between 1-10 to visually check how many random
numbers will fall between 1-10. Now I wanna take my array and apply a
method to it that will check which elements are less 21 but more then
10. For you math types 10<x<21. How do I accomplish that with ruby. Do I
accomplish it by doing it this way or am I overlooking a better method
for evaluating and comparing the elements in my array? I think I got the
right method but the block is wrong?
a = nums1.reject {|x| x<10 && x>21}
Heres what I have so far of my program:
nums = []
200.times do
nums << rand(100)
end
nums1 = nums.sort
nums1.each {|n| print n, “,” }
Please include the code so I can try it out on my editor and get it
figured out!
Thanks,
Matt