← Back to challenges

Check if an Array Contains a Given Number

JavaScriptHardarraysvalidationlanguage_fundamentals

Instructions

Write a function to check if an array contains a particular number.

Examples

check([1, 2, 3, 4, 5], 3) ➞ true

check([1, 1, 2, 1, 1], 3) ➞ false

check([5, 5, 5, 6], 5) ➞ true

check([], 5) ➞ false
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Minimal II: Boolean Redundancy