Created
July 9, 2019 15:05
-
-
Save TamaHills/c5c828ef157f033bb0b584580f15de50 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 longestString(strings) { | |
| var longString = '' | |
| strings.forEach((str => { | |
| longString = str.length > longString.length ? str : longString | |
| })) | |
| return longString | |
| } | |
| const strings1 = ['short', 'really, really long!', 'medium']; | |
| console.log(longestString(strings1)); // <--- 'really, really long!' | |
| const strings2 = ['short', 'first long string!!', 'medium', 'abcdefghijklmnopqr']; | |
| console.log(longestString(strings2)); // <--- 'first long string!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment