JavaScript: String reverse

Last update: 14 Sep 07:29
0
Students

reverse.js

Implement and export as default a function that reverses a string backwards using recursion.

Examples:

import reverse from './reverse';

reverse('str');    // rts
reverse('hexlet'); // telxeh

Try to solve this problem using a recursive process. To do this, you will need the slice() method.

Tips

  • To get a string length use the str.length
  • To get a string's substring use the slice() method: javascript 'welcome'.slice(1, 4); // 'elc';

For full access to the challenge you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
1000
exercises
2000+
hours of theory
3200
tests