I am using string and array prototype to add method. I just want to know why we need to use return statement in string in this example. I use return with array in this example but it is only returning first element in the array. Also when I use return it does not given result in console unless I store them in new array. fiddle
Array.prototype.u= function(){
for(i=0; i<this.length;i++){
this[i]= this[i].toUpperCase();
}
}
var ar= ['a','b','c','d','e','f']
ar.u()
console.log(ar)
String.prototype.u= function (){
return this.toUpperCase();
}
var st= "bingo"
st.u();
console.log(st)