15 lines
355 B
JavaScript
15 lines
355 B
JavaScript
|
function find_longest_word(str)
|
||
|
{
|
||
|
var array1 = str.match(/\w[a-z]{0,}/gi);
|
||
|
var result = array1[0];
|
||
|
|
||
|
for(var x = 1 ; x < array1.length ; x++)
|
||
|
{
|
||
|
if(result.length < array1[x].length)
|
||
|
{
|
||
|
result = array1[x];
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
console.log(find_longest_word('Web Development Tutorial'));
|