Created
November 10, 2016 19:10
-
-
Save rich-97/b68a12559ec81a08c6454be2959fd87e to your computer and use it in GitHub Desktop.
the longest word in javascript
This file contains 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
'use strict'; | |
const str = 'example example2 proof guide'; | |
const arr = str.split(' '); | |
const arrLength = []; | |
for (let i of arr) arrLength.push(i.length); | |
const max = Math.max.apply(null, arrLength); | |
for (let i = 0; i < arr.length; i++) { | |
if (max === arr[i].length) console.log(arr[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment