.includes doens't work for some reason in my javascript code for a chess.com chrome extension

44 views Asked by At
(() => {
    let move;
   
    function lastMove() {
        move = document.getElementsByClassName('white node');
        let previousMove = Array.from(move);
        console.log(previousMove.pop().textContent);
        return previousMove.pop().textContent;
    }
    
    chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
        let taken = lastMove();
        // lastMove(); returns the string b3
        if(taken.includes("b")) {
            console.log('it worked');
        }
        
    });

})();

I'm building a chrome extension for chess.com. The function lastMove() returns "b3". I thought that by using .includes("b"), I could get the if statment running but it does not run as expected. For some reason, the .includes function doesn't work and I'm not sure why. Any help is appreciated.

0

There are 0 answers