Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 467 Bytes

8 kyu - You only need one - Beginner.md

File metadata and controls

24 lines (20 loc) · 467 Bytes

Task

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

Alternate solutions

def check(arr,element)
  arr.any?(element)
end
def check(arr,element)
  !!arr.index(element)
end