JS判断是正数还是负数函数:

function check(x){
  if(x>0){
    return '正数';
  }else if(x<0){
    return '负数';
  }else{
    return 0;
  }
}

示例: