GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaScript/String/ReverseString.js at master · TheAlgorithms/JavaScript Expand file tree/ Copy pathReverseString.jsMore file actions 32 lines (27 loc) · 765 Bytes / Copy pathReverseString.jsFile metadata and controls32 lines (27 loc) · 765 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 /** * A short example showing how to reverse a string. */ function ReverseStringIterative(string) { if (typeof string !== 'string') { throw new TypeError('The given value is not a string') } let reversedString = '' let index for (index = string.length - 1; index >= 0; index--) { reversedString += string[index] } return reversedString } /** * * @author dev-madhurendra * Reverses a number by converting it to a string. * * @param {string} str - The number to reverse. * @returns {string} The reversed number. * * @example * const reversed = reverseString("hello"); // Returns olleh */ const ReverseStringIterativeInplace = (str) => [...str].reverse().join('') export { ReverseStringIterative, ReverseStringIterativeInplace } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |