Created
September 23, 2015 18:21
-
-
Save kosalvann/00b8e67d339b8bb4d63d to your computer and use it in GitHub Desktop.
Define a function reverse() that computes the reversal of a string. For example, reverse("jag testar") should return the string "ratset gaj".
This file contains 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
// Define a function reverse() that computes the reversal of a string. | |
// For example, reverse("jag testar") should return the string "ratset gaj". | |
// https://jsfiddle.net/L678qvLy/ | |
function reverse(str) { | |
var text = ''; | |
for (var i = str.length - 1; i >= 0; i--) { | |
text += str[i]; | |
continue | |
} | |
return text.toLowerCase(); | |
} | |
console.log(reverse("Kosal")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment