Gist 9a5e7b204b7bb4e90cc3f9b7bf5b7dad
✓ Published0🌍 Public
MMistyBlunch
Last edited Jun 10, 2019
Created on Jan 19, 2019
This example shows a recursive JavaScript function that reverses a string. The function `rec` takes a word, checks if its length is zero, and returns an empty string as the base case; otherwise, it appends the last character to the result of calling `rec` on the string with that last character removed. It demonstrates the reversal of the input "hello" to "olleh" through a simple recursion pattern. The code uses plain JavaScript with no external libraries or rendering APIs.
AI-generated description