Why RGB is not working when it us put inside double quote and works only on single quote?( Js )

here is the code…


    let btn = document.querySelector('button');

    function random(number){
        return Math.floor(Math.random()* number);

    function randColor(){
        let ranCol = "rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ' )";
        document.body.style.backgroundColor = ranCol;

    btn.onclick = randColor;

Hello @code-hunter

cause you use single quote inside so if you used single quote that would be as if
‘rgb(’ +…(+ and the whatever come after it will be outside the qoute)

hope that help and have a nice day :slight_smile: