Created
April 27, 2018 22:56
-
-
Save alisonailea/ddb3778df7a935cc1fd0c5bacbb6d902 to your computer and use it in GitHub Desktop.
CodeChallenge: Reversed Strings
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
/* | |
* 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