Last active
January 27, 2020 13:30
-
-
Save luojiyin1987/ee53cb893dd15bf5a9725e0134c46301 to your computer and use it in GitHub Desktop.
haveSameContents javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const haveSameContents = (a,b) => { | |
| for(const v of new Set([...a, ...b])) | |
| if (a.filter(e => e === v).length !== b.filter(e => e===v).length) | |
| return false; | |
| return true; | |
| }; | |
| console.log(haveSameContents([1,2,4], [2,4,1])); | |
| const isNumber = val => typeof val === 'number' && val === val; | |
| console.log(isNumber(1)); | |
| console.log(isNumber('1')); | |
| console.log(isNumber(NaN)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment