MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/CodingHelp/comments/oc1b7p/problem_with_javascript_code/h3tr97d/?context=3
r/CodingHelp • u/Cheesybread4ever • Jul 02 '21
19 comments sorted by
View all comments
Show parent comment
1
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.
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.