Created
April 4, 2017 02:11
-
-
Save kevmor11/4b5d36c141dc4cd36fc9aac840abcc20 to your computer and use it in GitHub Desktop.
reverses strings passed as arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse (string) { | |
var result = ""; | |
for (var i = string.length-1; i >= 0; i--) { | |
result += string[i]; | |
} | |
return result; | |
}; | |
for (var i = 2; i < process.argv.length; i++) { | |
var string = process.argv[i]; | |
console.log(reverse(string)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment