I added a function to returning my function by reverse order, later while i call it, i can’t get the result. instead the error thrown.
any one tell me the way i do is wrong?
String.prototype.reverse = function(st){
return st.split('').reverse().join('');
}
var myString = "sample string to reverse";
var reversed = myString.reverse();
i understand my way is wrong. any one can help me to my function corrected?
Use ‘this’. As you are not passing any parameter to reverse.