Back to Freecodecamp

Challenge 177: String Mirror

curriculum/challenges/english/blocks/daily-coding-challenges-javascript/69738771fb5a7b8b24cca2a3.md

latest981 B
Original Source

--description--

Given a string, return a new string that consists of the given string with a reversed copy of itself appended to the end of it.

--hints--

mirror("freeCodeCamp") should return "freeCodeCamppmaCedoCeerf".

js
assert.equal(mirror("freeCodeCamp"), "freeCodeCamppmaCedoCeerf");

mirror("RaceCar") should return "RaceCarraCecaR".

js
assert.equal(mirror("RaceCar"), "RaceCarraCecaR");

mirror("helloworld") should return "helloworlddlrowolleh".

js
assert.equal(mirror("helloworld"), "helloworlddlrowolleh");

mirror("The quick brown fox...") should return "The quick brown fox......xof nworb kciuq ehT".

js
assert.equal(mirror("The quick brown fox..."), "The quick brown fox......xof nworb kciuq ehT");

--seed--

--seed-contents--

js
function mirror(str) {

  return str;
}

--solutions--

js
function mirror(str) {
  const reversed = str.split("").reverse().join("");
  return str + reversed;
}