JS Built-ins
← Array173 / 226
ArrayArray.prototype.somebeginner

Array.prototype.some() β€” long string check

πŸ“– Usage Example
const words = ['cat', 'dog', 'elephant']
words.some(w => w.length > 5)  // β†’ true ('elephant')

Use some() to check whether any string in an array meets a length or pattern condition.

Array.prototype.some() β€” strings

some() works on arrays of any type. You can inspect string properties like .length inside the predicate.

Challenge: Implement hasLong(strs, minLen) that returns true if any string has length >= minLen.

hasLong(['hi', 'hello', 'hey'], 5) // β†’ true
hasLong(['hi', 'hey'], 5)          // β†’ false
πŸ’‘ Hints (2)
  • β€’ Access `.length` on each string inside the predicate: `s => s.length >= minLen`.
  • β€’ `some()` stops as soon as the first matching string is found.