JSFiddle - React, Tailwind, and code Playground

by shurikation

JavaScript

class PolindromString extends String{
    constructor(str){
        this.str = str;
    }
}
PolindromString.prototype[Symbol.iterator] = function(){
    let current = this.length
    console.log(this.lenght)
    return {
        next(){
            document.write(this)
            if(current >= 0){
                
                tmp= {
                    done: false,
                    value: this[current]
                }
                current--;
                return tmp;
            }else{
                return {
                    done: true
                }
            }
        }
    }
}

let str = new PolindromString('abcdefg');

let i = str[Symbol.iterator]()
document.write(i.next());

/* for(let ch of str){
    console.log(ch);
} */