folks, I'm trying to find out what word
is the longest in an entered sentence but the code is not outputting anything. Could smb please help me with that?
<!DOCTYPE html>
<html>
<head lang = "en">
<meta charset = "UTF-8">
<title>LongestWord</title>
</head>
<body>
<script language = "Javascript" type = "text/javascript">
var sentence = prompt("Enter sentence: ");
var splitted = sentence.split("\\s+");
var longestWord = splitted[0];
for(var i = 0; i < splitted.length; i++){
for(var j = 0; j < splitted[i].length - 1; j++){
if(longestWord.length < splitted[i].length){
longestWord = splitted[i];
}
}
}
document.write("The longest word in the sentence is " + longestWord);
</script>
</body>
</html>