Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 590 Bytes

you_only_need_one_beginner.md

File metadata and controls

22 lines (18 loc) · 590 Bytes

Description

You will be given an array a and a value x. All you need to do is check whether the provided array contains the value.

Array can contain numbers or strings. X can be either.

Return true if the array contains the value, false if not.

My Solution

def check(arr,element)
  arr.include?(element)
end

Better/Alternative solution from Codewars

def positive_sum(arr)
  arr.select{|x| x > 0}.reduce(0, :+)
end