Skip to content

Instantly share code, notes, and snippets.

@alisonailea
Created April 27, 2018 22:56
Show Gist options
  • Save alisonailea/ddb3778df7a935cc1fd0c5bacbb6d902 to your computer and use it in GitHub Desktop.
Save alisonailea/ddb3778df7a935cc1fd0c5bacbb6d902 to your computer and use it in GitHub Desktop.
CodeChallenge: Reversed Strings
/*
* Due to an API bug we are getting reversed text
* Write a function that takes an array of reversed strings and returns an array of unreversed strings.
*/
const reversedStrings = ["selciheV cirtcelE muimerP", "ssenisuB ro emoH ruoy rewoP ylbaniatsuS"];
function fixReversedStrings(strings) {
const newArray=[];
strings.forEach(str => {
const newString = str.split('').reverse().join('');
newArray.push(newString);
})
return newArray;
}
console.log(fixReversedStrings(reversedStrings));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment