# [2704. To Be Or Not To Be](https://leetcode.com/problems/to-be-or-not-to-be/description/?envType=study-plan-v2&envId=30-days-of-javascript)  題目要求我們寫兩個function 一個tobe nottobe 並且在個別達成時return false時throw 但由於throw是直敘式 沒辦法回傳固定文字 所以我們寫一個func來接他並回傳 ```js= const expect = (val) =>{ throwErr = (str)=>{ throw new Error(str); } toBe = (val2) =>{ return val === val2? true : throwErr("Not Equal") ; } notToBe = (val2) =>{ return val !== val2? true : throwErr("Equal") ; } return {toBe,notToBe}; }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up