Skip to content

Instantly share code, notes, and snippets.

@mstepniowski
Created July 30, 2011 13:05
Show Gist options
  • Save mstepniowski/1115506 to your computer and use it in GitHub Desktop.
Save mstepniowski/1115506 to your computer and use it in GitHub Desktop.
getReversed - A solution to one of the problems on meet.js Warsaw
function getReversed (str) {
var i, idx, result = [];
for (i = 0; i < str.length; ++i) {
idx = (i % 2) ? (str.length - Math.ceil((i + 1) / 2)) : Math.ceil(i / 2);
result.push(str[idx]);
}
return result.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment