console.log(repeat('Ha!'));
console.log(repeat('Ha!',2));
console.log(repeat('Ha!',3));
console.log(repeat('Ha!',5));

function repeat(str, val)
{
    var st = str.split(' ')
    
    if(val<0)
    {
        return 'Invalid';
    }
    else
    {
        for(var i =0 ; i<val-1 ; i++)
        {
           st.push(str)
        }
        return st.join('')
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: