Check if function returns true to execute another function

前端 未结 4 499
感动是毒
感动是毒 2021-02-05 14:14

I have written a form validation using JS which ends with return(true);

function check() {
  ....validation code
  return(true);
}

All I want i

4条回答
  •  梦如初夏
    2021-02-05 15:01

    You should use return true; and your if statement doesn't need the === true comparison.

    function check() {
      //validation code
      return true;
    }
    
    if(check()) {
      //Another function code
     }
    

    JSFIDDLE

提交回复
热议问题