Exercise: Number Sequence
Explore how to apply conditional expressions in ReasonML by writing a function to generate the next number in a sequence. Learn to handle valid input ranges and edge cases to build confidence in using if-else, switch, or ternary operators.
We'll cover the following...
We'll cover the following...
Problem Statement
Given an integer, n, between 0 and 9, generate the n+1 number.
You can use your preferred conditional to solve this problem.
Sample Input
n = 3
Sample Output
4
Coding Challenge
Take some time to figure out all the possible cases for the values of n. Keep in mind that n can go up to 9, which means the last number in the whole sequence will be 10.
For any value of n outside the specified range, just return -1.
If you feel stuck, you can always check out the solution review in the next lesson.
Good luck!