Search code examples
javascriptcomparison-operators

Comparison Operators - Greater than or Equal to - Not Working


Just started using JQuery recently. (Fairly recently, I suppose...) What am I doing wrong here?

var userDate = new Date();
if(userDate.getHours() => 12)
{
    var post = $('p[title="test"]');
    post.text('Would you look at the time?');
}

Solution

  • The condition is flipped.

       var userDate = new Date();
        if(userDate.getHours() >= 12)
        {
            var post = $('p[title="test"]');
            post.text('Would you look at the time?');
        }