January 2020
Intermediate to advanced
470 pages
11h 13m
English
9.1. Into reverse: An empty string is reversed by simply doing nothing. To reverse a non-empty string, remove its first character, reverse the rest, and append the removed character at the end. For example, reverse("MONTEVIDEO") can be found by using reverse("ONTEVIDEO")+"M". In the same way, reverse("ONTEVIDEO") would be equal to reverse("NTEVIDEO")+"O", and so on:
const reverse = str => str.length === 0 ? "" : reverse(str.slice(1)) + str[0];
9.2. Climbing steps: Suppose we want to climb a ladder with n steps. We can do this in two ways:
So, if we call ladder(n)
Read now
Unlock full access