...

/

Coding Challenge: Using Option in Function

Coding Challenge: Using Option in Function

Let's use Option monad in a function in this coding challenge.

We'll cover the following...

Problem statement

Write a function called safeDivide that takes two parameters called value and divisor, both of type number. If the divisor isn’t equal to 0, the function divides the value by the divisor and returns the result wrapped in an option. Otherwise, the function returns an empty optional.

Try it yourself

Access this course and 1400+ top-rated courses and projects.