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 — JavascriptAlgorithm/String/ReverseWords.js at master · Twivbas/JavascriptAlgorithm Expand file tree/ Copy pathReverseWords.jsMore file actions 15 lines (14 loc) · 467 Bytes / Copy pathReverseWords.jsFile metadata and controls15 lines (14 loc) · 467 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 const reverseWords = (str) => { // Split string into words // Ex. "I Love JS" => ["I", "Love", "JS"] const words = str.split(' ') // reverse words // ["I", "Love", "JS"] => ["JS", "Love", "I"] const reversedWords = words.reverse() // join reversed words with space and return // ["JS", "Love", "I"] => "JS Love I" return reversedWords.join(' ') } // testing console.log(reverseWords('I Love JS')) console.log(reverseWords('My Name Is JavaScript')) |
| You are visitor 01402520 — 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. |