Solution Review: Number Sequence
This lesson will explain the solution for the number sequence exercise.
We'll cover the following...
Solution 1: switch
Expression
Press + to interact
let n = 5;let next = switch (n) {/* Take care of all cases */| 0 => 1| 1 => 2| 2 => 3| 3 => 4| 4 => 5| 5 => 6| 6 => 7| 7 => 8| 8 => 9| 9 => 10| _ => -1 /* In case n is out of range */};Js.log(next);
...