This article is participating in the nuggets team number online activity, click to see the dachang spring recruiting positions

I. Title Description:

Write a function in JavaScript that enters an int and returns the string in reverse order of an integer. For example, if you enter integer 1234, the string 4321 is returned. You must use recursive function calls, not global variables, input functions must have only one argument passed in, and must return a string.

Ii. Analysis of Ideas:

The second to the end of the string is taken as the parameter of the next recursive function to determine whether the length of the current string is equal to 1. If the length is equal to 1, the string is returned. If the length is greater than 1, the recursive call is made

Iii. AC Code:

      function numberReverse(num) {
        const str = num.toString();
        return str.length === 1
          ? str
          : numberReverse(str.substring(1)) + str.substring(0.1);
      }
      console.log(numberReverse(1234));
      
Copy the code

Iv. Summary:

Try to get to a Nuggets event and check in;