Skip to content

Instantly share code, notes, and snippets.

@kosalvann
Created September 23, 2015 18:21
Show Gist options
  • Save kosalvann/00b8e67d339b8bb4d63d to your computer and use it in GitHub Desktop.
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".
// 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