Find if variable is divisible by 2

前端 未结 12 507
梦谈多话
梦谈多话 2020-12-07 19:22

How do I figure out if a variable is divisible by 2? Furthermore I need do a function if it is and do a different function if it is not.

12条回答
  •  Happy的楠姐
    2020-12-07 19:58

    Please write the following code in your console:

    var isEven = function(deep) {
    
      if (deep % 2 === 0) {
            return true;  
        }
        else {
            return false;    
        }
    };
    isEven(44);
    

    Please Note: It will return true, if the entered number is even otherwise false.

提交回复
热议问题