I have a problem with a variable string but return [Object object]
$(document).ready(function () {
$(".story-area > h1").text(function () {
return $(this).text(convertString($(this).text()));
});
$(".story-area > p").text(function () {
return $(this).text(convertString($(this).text()));
});
$(".story-area > div > p").text(function () {
return $(this).text(convertString($(this).text()));
});
});
function convertString(current_text) {
var arr_text = current_text.split(' ');
var new_text = '';
for (i = 0; i < arr_text.length; i++) {
if (arr_text[i].length > 4) {
new_text += arr_text[i].replace(/[Hh][Ii]/g, 'HIV') + ' ';
} else {
new_text += arr_text[i] + ' ';
}
}
return new_text;
}
The new_text value returns [Object object] instead of the string value. Any errors on my code?

new_textis[Object object]?$(this).text(convertString($(this).text()))is an object.$(".story-area > h1, .story-area > p, .story-area > div > p").text(convertString). Also why don't you link to the fiddle, or better create a runnable demo here?