I am learning javascript & Node.js. For some reason this IF statement is not working as I would've expected...
I cannot figure out how to solve this...
My code:
process.stdin.setEncoding('utf8');                      //Set UTF charcode
process.stdin.on('readable', () => {                    //Event fires when there's input
    var readConsole = process.stdin.read();             //Receive the input from console
    if(readConsole != null) {
        readConsole.trim().replace(/\r?\n|\r/g, " ");   //Trim input and remove line breaks
        process.stdout.write('Input: ' + readConsole);  //Output the input
        if(readConsole == "quit") {
            process.exit();
        }
    }
});
But for some reason, whenever I type "quit" in the console, it does not respond.
Here is an image of the problem:

 
     
    