check if javascript function is true

JavaScript
function example(){
  return true;
}

if(example()){ 
  console.log('hello');
}else{
  console.log('bye');
}

// result: 'hello'
Source

Also in JavaScript: