String replacement

String.prototype.jumpText = function(){

            var res = this

            for( var i=0; i<res.length; i+=2){

                console.log(res[i], res[i].toUpperCase());

                res = res.replace(res[i], res[i].toUpperCase());

                console.log(res[i].toUpperCase());

            }

        console.log(res);

        }

this is my code to replace alternative string but it’s only working for 4 to 5 long strings
like, “amit”.jumpText()
it gives aMiT.
but it doesn’t work for long strings

i dont get what is wrong here because its working fro me ,u can use alternative way ,like -take a empty string and add the every +2 upperCase letter through looping
here is ur old one

res =“prakash”
for( var i=0; i<res.length; i+=2){
res = res.replace(res[i], res[i].toUpperCase());
}
console.log(res);