To write a JavaScript function to the console, simply use the console.log() method.

<script>
 function myFunc(){
  return 5 + 5
 }
 console.log(myFunc())
</script>
// output => 10