You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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'));