Created
August 18, 2021 05:46
-
-
Save blacksheep557/bd4170bd512939bc01c9cbe347a2e0f7 to your computer and use it in GitHub Desktop.
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
| function validIp(ip) { | |
| const ipArray = ip.split(".") | |
| console.log(ipArray.length) | |
| return ipArray.length === 4 && !ipArray.some(address => 0 > Number(address) || Number(address) > 255) | |
| } | |
| console.log(validIp('1.2.3.4')) | |
| console.log(validIp('123.45.67.89')) | |
| console.log(validIp('1.2.3.4.5')) | |
| console.log(validIp('1.2.3')) | |
| console.log(validIp('123.456.78.90')) | |
| function likesInfo(names) { | |
| if (names.length === 1) { | |
| return `${names[0]} likes this` | |
| } else if (names.length === 2) { | |
| return `${names[0]} and ${names[1]} like this"` | |
| }else if (names.length === 3) { | |
| return `${names[0]}, ${names[1]} and ${names[2]} like this` | |
| }else if (names.length === 4){ | |
| return `${names[0]}, ${names[1]} and ${names.length - 2} others like this` | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment