DEV Community

Discussion on: Every problem has another solution

Collapse
 
elanid profile image
Daniel J Dominguez

For the name swapping regular expression one, you can make it shorter by using a replace method.

string.replace(/(\w+) (\w+)/, "$2, $1")
Collapse
 
mateuszniestroj profile image
Mateusz Niestrój

So we have another way :) Great job!