Add exercice about 'if' (#40)

*  add bonus (about if) in exo1

* ♻️ improve bonus

* 🔥 remove not clear exercice

* ♻️ better bonus explanations

* ♻️ spaces
This commit is contained in:
Justine Mignot 2022-05-13 14:04:01 +02:00 committed by GitHub
parent a499a93364
commit eb34020b8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,17 @@ export const divide = (a: number, b: number): number => {
export const safeDivide: (a: number, b: number) => Option<number> =
unimplemented;
// You probably wrote `safeDivide` using `if` statements and it's perfectly valid!
// There are ways to not use `if` statements.
// Keep in mind that extracting small functions out of pipes and using `if` statements in them
// is perfectly fine and is sometimes more readable than not using `if`.
//
// BONUS: Try now to re-write `safeDivide` without any `if`
//
// HINT: Have a look at `fromPredicate` constructor
///////////////////////////////////////////////////////////////////////////////
// EITHER //
///////////////////////////////////////////////////////////////////////////////