DEV Community

loading...

Discussion on: Daily Challenge #124 - Middle Me

Collapse
savagepixie profile image
SavagePixie • Edited

If X cannot be placed in the middle, return X.

I interpret that this means if it can't be placed in the exact middle position, i.e., N is odd. Otherwise, I don't know how to understand this statement.

const middleMe = (x, y, n) => n % 2 != 0
   ? x
   : `${y.repeat(n/2)}${x}${y.repeat(n/2)}`