Upon running the code snippet below:
<script>
var name = "Hello moorthi";
var myArray = name.split(' ');
setTimeout(function(){
var nameDisplay='';
try {
for (var names in myArray){
nameDisplay += myArray[names].toUpperCase()+' ';
}
alert(nameDisplay);
}
catch(err){
console.log(err.message);
}
},
1000);
</script>
An error message stating 'undefined is not a function' appears in Chrome. Can anyone provide insight into why this issue is occurring?