I am once again doing some Selenium automation in JavaScript and I have some methods that return boolean values about the webpage. For instance, I have a method isB2B() which returns whether the order form I'm automating is for a B2B order. It relies on the private #getMarketType() method, which returns either the Market Type as a string or false, depending on whether it was able to retrieve the market type from the page using Selenium. I would like the return value for the isB2B() method to indicate both the success value of the retrieval and whether the market type was B2B. In Rust, I would use the enum
Result<bool, ()>
which could have either variant of
Ok(bool)
or
Err(())
How can I achieve similar functionality in JavaScript?