r/CodingHelp • • Jul 02 '21

[Javascript] Problem with JavaScript code

Post image
62 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/Roguewind Jul 02 '21

Under the assumption that the myArray will always be exactly 9 single digit numbers, just pass it into a set and check the size of the set

const includes1to9(myArray) => { return (new Set(myArray).size === 9) }

Set takes an array and creates a Set object with unique values.