Skip to main content
17-Peridot
August 8, 2022
Solved

For certain conditions, how to terminate the code without throwing error.

  • August 8, 2022
  • 2 replies
  • 968 views

For certain conditions, how to terminate the code without throwing error.

Best answer by DanZ

Hi,

put your whole code in a self-executing function block and "return" if you want to end the execution.

 

const result = (function() {
 // Your code here
 // To end it all, simply "return"
})();

 

Or if you prefer the arrow function syntax:

const result = (() => {
 // Your code here
})();

 

2 replies

DanZ15-MoonstoneAnswer
15-Moonstone
August 8, 2022

Hi,

put your whole code in a self-executing function block and "return" if you want to end the execution.

 

const result = (function() {
 // Your code here
 // To end it all, simply "return"
})();

 

Or if you prefer the arrow function syntax:

const result = (() => {
 // Your code here
})();

 

Support
August 24, 2022

Hi @AP_9587236.

 

To answer your question, we need to understand the conditions you refer to.  Can you provide some details of your use case?

 

Regards.

 

--Sharon