you should use handler function in map:
var array2 = ["melon","banana","apple","orange","lemon"];
array2 = array2.map(function(x){ return x.toUpperCase(); })
for more information about map
edit: yes you can do
toUpper = function(x){
return x.toUpperCase();
};
array2 = array2.map(toUpper);